python - 我不清楚 GridSearchCV 中 best_score_ 的含义
问题描述
我对几个模型进行了实验,并为每个模型生成了一个最佳分数,以帮助我决定为最终模型选择一个。使用以下代码生成了最好的分数结果:
print(f'Ridge score is {np.sqrt(ridge_grid_search.best_score_ * -1)}')
print(f'Lasso score is {np.sqrt(lasso_grid_search.best_score_ * -1)}')
print(f'ElasticNet score is {np.sqrt(ElasticNet_grid_search.best_score_ * -1)}')
print(f'KRR score is {np.sqrt(KRR_grid_search.best_score_ * -1)}')
print(f'GradientBoosting score is {np.sqrt(gradientBoost_grid_search.best_score_ * -1)}')
print(f'XGBoosting score is {np.sqrt(XGB_grid_search.best_score_ * -1)}')
print(f'LGBoosting score is {np.sqrt(LGB_grid_search.best_score_ * -1)}')
结果发布在这里:
Ridge score is 0.11353489315048314
Lasso score is 0.11118171778462431
ElasticNet score is 0.11122236468840378
KRR score is 0.11322596291030147
GradientBoosting score is 0.11111049287476948
XGBoosting score is 0.11404604560959673
LGBoosting score is 0.11299104859531962
我不知道如何选择最好的模型。在这种情况下,XGBoosting 是我最好的模型吗?
解决方案
但是,您的代码未从ridge_grid_search
我想您sklearn.model_selection.GridSearchCV
用于模型选择的名称中提供。GridSearch 应该用来调整单个模型的超参数,而不应该用来比较不同的模型。ridge_grid_search.best_score_
返回在给定算法的网格搜索期间找到的最佳超参数所获得的最佳分数。
对于模型比较,您应该使用交叉验证算法,例如k 折交叉验证在使用交叉验证时,请确保每个模型都在相同的训练/测试集上进行训练和测试,以便进行公平比较。
推荐阅读
- javascript - 在 webrtc 期间播放声音/从其他音频元素获取播放设备
- html - 如何使动画以不触发它的元素为目标?
- c++ - 尝试使用数组中的 int 进行除法,尝试 C++ 时会出现垃圾数字
- typescript - 有什么方法可以在 Deno 中获取 Buffer 的地址吗?
- reactjs - 在不使用模式窗口的视频上实现全屏
- r - 删除包含 R 中特定单词的行
- ios - 在 Firebase Analytics 中禁用 IDFA 与 Google Analytics 冲突
- html - 为什么在边距中使用“0 auto”,而不是“auto”?
- python-3.x - 为什么当循环数变大时对设置的打印值进行排序?
- python - 正则表达式提取