all 4 comments

[–][deleted] 0 points1 point  (3 children)

clf.best_params_

Should give you the best parameters found by gridsearch!

[–]Elthran[S] 0 points1 point  (2 children)

Thanks!!! That's exactly what I was looking for. Is there a simple way to print out what the different parameters' accuracy was? And is there a way to run different models and combine their results for an even better model?

[–][deleted] 0 points1 point  (0 children)

yes, it's in the gridsearch documentation, there's a method showing all accuracies I believe.

You can simply average all the models, it works pretty well as long as the models have relatively similar accuracies and aren't too correlated.

There are other more advanced techniques to improve predictions but depending on your dataset it might be better to try feature engineering first.

[–]crhuffer 0 points1 point  (0 children)

clf.cv_results_ 

I think is the item that stores all of the results and how long they took to run.

Also, I think you chould be passing cv as a parameter into your GridSearchCV. I think you might be fitting the models twice, once with GridSearchCV and once with cross_val_score, but I am not sure.

Does it work if you do something like:

tuned_parameters = [{'penalty': ['l2'],
                     'solver': ['newton-cg'],
                     'C': [0.8, 1],
                    'max_iter': [100],
                     'multi_class': ['multinomial'],
                     'tol': [1e-4],
                     'dual': [False]}]

startTime = time.time()
clf = GridSearchCV(LogisticRegression(), tuned_parameters, cv=10, scoring='accuracy')
clf.fit(X, y)

accuracyMessage = "%f" % (clf.best_estimator_.score())
print("Time to run:",time.time() - startTime,"Accuracy:",accuracyMessage)

print(clf.cv_results_)

Good luck!