如何使用 Scikit-learn 中的 OneVsRestClassifier 来分析预测每个个体 class 与 multi-class classification 的性能?

How to use the OneVsRestClassifier in Scikit-learn to analyse the performance of predicting each individual class with multi-class classification?

在 scikit-learn 网站上的 OneVsRestClassifier 文档中,它声明如下:

"Since each class is represented by one and one classifier only, it is possible to gain knowledge about the class by inspecting its corresponding classifier."

但它没有解释如何做到这一点,我看不出该页面文档中的任何方法如何实现这一点。我希望能够为每个人 class 打印出模型的准确性,以便我可以看到它在预测每个 class 时的表现。

我目前的代码在下面,但我真的不知道从哪里开始,因为文档中似乎没有任何内容解释如何执行此操作。非常感谢任何帮助。

def predict_one_vs_rest(self):
    clf = OneVsRestClassifier(LinearSVC(random_state=0))
    clf.fit(self.X, self.y)
    result = clf.classes_
    estimators = clf.estimators_
    print(result)
    print("")
    print(estimators)

您不需要将 LinearSVC 包装在 OneVsRestClassifier 中。正如 documentation 明确指出的那样,LinearSVC 已经支持多 class class 化。 例如,为了检查 classes 的准确性,您可以使用混淆矩阵或 class化验报告。