【问题标题】:How can I know which parameters were tested by RandomizedSearchCV?我如何知道 RandomizedSearchCV 测试了哪些参数?
【发布时间】:2021-01-18 02:13:18
【问题描述】:

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)

【问题讨论】:

    标签: python scikit-learn grid-search gridsearchcv


    【解决方案1】:

    属性cv_results_ 中提供了大量有关搜索的信息。将该 dict 导入数据框,您会为每个测试的超参数组合获得一行,其中包含超参数值、折叠和平均分数、可选的训练分数、训练时间等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-29
      • 1970-01-01
      • 1970-01-01
      • 2022-12-03
      • 1970-01-01
      相关资源
      最近更新 更多