【发布时间】:2021-01-18 02:13:18
【问题描述】:
RandomizedSearchCV 很有用,因为它不会尝试您列出它要尝试的所有参数。相反,它会显示一些并测试它们,看看哪个更好。
但是我怎么知道测试了哪些参数呢?
例如,在下面的脚本中,测试了n_estimators、max_features 和max_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