Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What replaces GridSearchCV._grid_scores_ in scikit?

Since _grid_scores_ method has been replaced by cv_results_ I would like to know how do I output the tuple with the parameters and scores? cv_results_ provides a dataframe for the score, but the tuple output was way easier to handle.

Please guide me towards handling parameter and score values in this new version of scikit. I plan to run a GridSearchCV for different ranges of parameters which I would latter consolidate into a single dictionary.

like image 397
Ankit Bansal Avatar asked Feb 05 '23 21:02

Ankit Bansal


1 Answers

Use the for loop to print the results from cv_results_ as they were in grid_scores_.

From the documentation example:

clf = GridSearchCV(init params...)
clf.fit(train data...)

print("Best parameters set found on development set:")
print(clf.best_params_)

print("Grid scores on development set:")
means = clf.cv_results_['mean_test_score']
stds = clf.cv_results_['std_test_score']

#THIS IS WHAT YOU WANT
for mean, std, params in zip(means, stds, clf.cv_results_['params']):
    print("%0.3f (+/-%0.03f) for %r"
          % (mean, std * 2, params))
like image 200
Vivek Kumar Avatar answered Feb 07 '23 10:02

Vivek Kumar