Reputation: 201
In the OneVsRestClassifier documentation on the scikit-learn website it states the following:
"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."
But it gives no explanation of how to do this and I can't see how any of the methods in the documentation on this page could achieve that. I want to be able to print out the accuracy of the model for each individual class, so that I can see the performance it has at predicting each class.
The code I have so far is below, but I really don't know where to go from here, as it seems that there is nothing in the documentation, which explains how to do this. Any help is much appreciated.
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)
Upvotes: 5
Views: 5034
Reputation: 28748
You don't need to wrap LinearSVC in OneVsRestClassifier. As the documentation clearly says, LinearSVC already supports multi-class classification. For inspecting accuracy of the classes, you could use the confusion matrix or the classification report, for example.
Upvotes: 4