Reputation: 1153
I have trained my classifier on 3 dialects using text classification. And this was the confusion matrix and precision:
confusion matrix
[[27 6 0 16]
[ 5 18 0 21]
[ 1 3 6 9]
[ 0 0 0 48]]
The precision
[0.81818182 0.66666667 1. 0.5106383 ]
How to know which row in the confusion matrix and which element in the precision belong to what dialect I have? I provided the training data to the classifier with the following labels :
Egyptian
Sudan
Iraqi
Jordan
Here's the code, I used RandomForestClassifier:
from sklearn.ensemble import RandomForestClassifier
classifier = RandomForestClassifier(n_estimators=1000, random_state=0)
classifier.fit(X, labels)
test_pred = classifier.predict(y)
precision_score(labels_test,test_pred,average=None)
output:
array([0.91024735, 0.94929397, 0.98622273, 0,95343322])
Upvotes: 0
Views: 673
Reputation: 5955
classifier.classes_
will give you the labels the classifier is scoring on in the order they are stored in the classifier object. That should be the same order as the outputs you've already got, though I would verify that with some spot-checking of your predictions to be sure
Upvotes: 1