april
april

Reputation: 131

f1 score for test data

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

Answers (1)

PieCot
PieCot

Reputation: 3639

You can compute the f1 score with:

Upvotes: 1

Related Questions