我如何知道哪些参数是由随机搜索CV测试的?

2024-04-26 19:02:27 发布

您现在位置:Python中文网/ 问答频道 /正文

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)

Tags: infor参数nprandomnummaxint
1条回答
网友
1楼 · 发布于 2024-04-26 19:02:27

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

相关问题 更多 >