Reputation: 131
To get the best f1 score of cross validation I do that
grid_search = GridSearchCV(pipeline, param_grid=param_grid, cv=10, verbose=10, scoring='f1')
grid_result = grid_search.fit(X_train, y_train)
print("best parameters", grid_search.best_params_)
print('Best score : {}'.format(grid_search.best_score_))
but for the Test score I also need f1-score not the accuracy
print("Test Score",grid_search.best_estimator_.score(X_test,y_test.reshape(y_test.shape[0])))
Is there any function e.g., f1_score()
that I can use or should I write the function myself?
Upvotes: 0
Views: 728
Reputation: 3639
You can compute the f1 score with:
the classification report
(example here)
the Scikit-learn f1_score function: (http://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html)
Upvotes: 1