Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 测试数据的f1分数_Python_Machine Learning_Scikit Learn - Fatal编程技术网

Python 测试数据的f1分数

Python 测试数据的f1分数,python,machine-learning,scikit-learn,Python,Machine Learning,Scikit Learn,为了获得交叉验证的最佳f1分数,我这样做 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_

为了获得交叉验证的最佳f1分数,我这样做

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_))
但对于测试分数,我也需要f1分数,而不是准确性

print("Test Score",grid_search.best_estimator_.score(X_test,y_test.reshape(y_test.shape[0])))

是否有任何函数(例如,
f1_score()
)我可以使用,或者我应该自己编写该函数?

您可以使用以下公式计算f1分数:

  • 分类报告
    ()

  • Scikit学习f1\U分数功能: ()