我如何知道RandomizedSearchCV测试了哪些参数?

问题描述

RandomizedSearchCV很有用,因为它不会尝试列出的所有参数。相反,它显示了一些并对其进行了测试以查看哪个更好。

但是我怎么知道测试了哪些参数?

例如,在下面的脚本中,测试了n_estimatorsmax_featuresmax_depth的哪些组合? n_estimator = 10经过测试了吗? n_estimator = 100经过测试了吗?

rf = RandomForestRegressor()

n_estimators = [int(x) for x in np.linspace(start=10,stop=2000,num=200)]
max_features = ["auto","sqrt","log2"]
max_depth = [int(x) for x in np.linspace(5,500,num=100)]

random_grid = {
"n_estimators": n_estimators,"max_features": max_features,"max_depth": max_depth,}

randomsearch = RandomizedSearchCV(rf,param_distributions=random_grid,cv=5)

randomsearch.fit(X_train,y_train)

解决方法

属性class DummyTestClass(unittest.TestCase): my_guard = False is_this_the_cicd_jenkins_machine = SomeClass.is_this_the_cicd_jenkins_machine() @attr(testsuite='SUITE_1') def test_a_change_my_guard(self): # purpose of test is only to change the guard so that test b will be run if testsute SUITE_1 is selected form Jenkins print('test a') globals()['my_guard'] = True # my_guard = True # also trying this,still my_guard is still false in test_b @unittest.skipIf(my_guard is False,'skip test_b') # @unittest.skipIf(globals()['my_guard'] is False,'skip test b') compilation error # @unittest.skipIf(is_this_the_cicd_jenkins_machine,‘script skipped’) # ugly solution @attr(testsuite='SUITE_1') def test_b(self): # controlled by guard print('test b') @attr(testsuite='SUITE_1') def test_c_to_be_run_in_suite_1(self): print('test c') 中提供了许多有关搜索的信息。将该dict导入数据框,您将为每个测试的超参数组合获得一行,其中包含超参数值,折叠和平均得分,可选的训练得分,训练时间等。