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 eg, f1_score()
that I can use or should I write the function myself?
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 )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.