Reputation: 4041
I am using sklearn to compute precision and recall for a binary classification project.
scores = cross_validation.cross_val_score(clf, numpy.asarray(X_features), numpy.asarray(Y_targets), \
cv = 5, score_func = metrics.metrics.precision_recall_fscore_support )
The scoring function I am using is metrics.metrics.precision_recall_fscore_support.
The partial output is as below:
[[[ 0.95652174 1. ]
[ 1. 0.95348837]
[ 0.97777778 0.97619048]
[ 44. 43. ], ......]
The first row is precision, the second row is recall. But since it is a binary classification, I wonder which column is for "0" class and which is for "1" class? If it is a multi-class classification, e.g. "0", "1", "2", how does sklearn order the classes in outputs?
Upvotes: 1
Views: 940
Reputation: 988
When using fit() you can get the corresponding classes in the same order through the classes_ property of the classifier model (ie. my_model.classes_).
It is not available in your case so use numpy.unique(Y_targets) => it is the same internal method used so it will be in the same order.
Upvotes: 2