如何通过sklearn获得平均精度,召回率,f1,交叉验证的准确性?

时间:2016-11-01 02:37:51

标签: python scikit-learn cross-validation

我在Weka的整个训练集上使用k-fold交叉验证进行超参数调整,它显示了交叉验证的平均精度,召回率,f1。我希望在python中使用Sklearn获得相同的结果。

    cv = StratifiedShuffleSplit(n_splits=5, test_size=0.2, random_state=42)
    grid = GridSearchCV(LinearSVC(), param_grid=param_grid, cv=cv)
    grid.fit(X_train, y_train)
    # print the best parameters
    print("The best parameters are %s with a score of %0.5f"
      % (grid.best_params_, grid.best_score_))
    # print the average precision, recall, f1, accuracy of cross 
    # validation with the best parameters found
    ???

任何人都可以提供帮助吗?

1 个答案:

答案 0 :(得分:0)

您可以使用classification_report中的sklearn.metrics功能。

article

相关问题