我不清楚GridSearchCV的最佳分数是什么意思

2024-04-16 23:18:30 发布

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

我用几个模型做了一个实验,并为每个模型得出了一个最好的分数,以帮助我决定选择哪一个作为最终模型。已使用以下代码生成最佳分数结果:

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

我不知道如何选择最好的型号。在这种情况下,XG是我最好的车型吗


Tags: 模型searchisnpsqrt分数gridbest
1条回答
网友
1楼 · 发布于 2024-04-16 23:18:30

您的代码没有提供,但是来自ridge_grid_search的名称。我想您正在使用^{}进行模型选择。GridSearch应用于调整单个模型的超参数,而不应用于相互比较不同的模型ridge_grid_search.best_score_返回在给定算法的网格搜索期间找到的最佳超参数所获得的最佳分数

对于模型比较,在使用交叉验证时,应使用交叉验证算法,如k-fold cross validation,确保在相同的培训/测试集上对每个模型进行培训和测试,以进行公平比较

相关问题 更多 >