How to graph grid scores from GridSearchCV?

前端 未结 10 1025
旧时难觅i
旧时难觅i 2021-01-30 03:19

I am looking for a way to graph grid_scores_ from GridSearchCV in sklearn. In this example I am trying to grid search for best gamma and C parameters for an SVR algorithm. My c

10条回答
  •  感情败类
    2021-01-30 03:53

    This worked for me when I was trying to plot mean scores vs no. of trees in the Random Forest. The reshape() function helps to find out the averages.

    param_n_estimators = cv_results['param_n_estimators']
    param_n_estimators = np.array(param_n_estimators)
    mean_n_estimators = np.mean(param_n_estimators.reshape(-1,5), axis=0)
    
    mean_test_scores = cv_results['mean_test_score']
    mean_test_scores = np.array(mean_test_scores)
    mean_test_scores = np.mean(mean_test_scores.reshape(-1,5), axis=0)
    
    mean_train_scores = cv_results['mean_train_score']
    mean_train_scores = np.array(mean_train_scores)
    mean_train_scores = np.mean(mean_train_scores.reshape(-1,5), axis=0)
    

提交回复
热议问题