简体   繁体   中英

Interpretation of the output of sklearn.metrics.precision_recall_fscore_support

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, eg "0", "1", "2", how does sklearn order the classes in outputs?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM