GridSearchCV-提示错误KeyError: ‘mean_train_score‘

代码:
test_means = grid.cv_results_[ ‘mean_test_score’ ]
test_stds = grid.cv_results_[ ‘std_test_score’ ]
train_means = grid.cv_results_[ ‘mean_train_score’ ]
train_stds = grid.cv_results_[ ‘std_train_score’ ]
错误:
GridSearchCV-提示错误KeyError: ‘mean_train_score‘_第1张图片
原因:没有指定训练级
解决:在 GridSearchCV()方法中增加 return_train_score=True
grid= GridSearchCV(lr_penalty, tuned_parameters,cv=3, scoring=‘neg_log_loss’,n_jobs = 4,return_train_score=True)
grid.fit(X_train,y_train)

你可能感兴趣的:(大数据,深度学习,机器学习,pytorch)