How to graph grid scores from GridSearchCV?

前端 未结 10 1003
旧时难觅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 04:11

    I wanted to do something similar (but scalable to a large number of parameters) and here is my solution to generate swarm plots of the output:

    score = pd.DataFrame(gs_clf.grid_scores_).sort_values(by='mean_validation_score', ascending = False)
    for i in parameters.keys():
        print(i, len(parameters[i]), parameters[i])
    score[i] = score.parameters.apply(lambda x: x[i])
    l =['mean_validation_score'] + list(parameters.keys())
    for i in list(parameters.keys()):
        sns.swarmplot(data = score[l], x = i, y = 'mean_validation_score')
        #plt.savefig('170705_sgd_optimisation//'+i+'.jpg', dpi = 100)
        plt.show()
    

提交回复
热议问题