1

Вывожу для тестовых данных посчитанные метрики:

print(classification_report(y_true, y_pred_classes,  target_names = CLASSES))

              precision    recall  f1-score   support

 **********0       0.87      0.88      0.87      1000

 **********1       0.99      0.98      0.99      1000

 **********2       0.86      0.89      0.87      1000

 **********3       0.93      0.93      0.93      1000

 **********4       0.87      0.88      0.88      1000

 **********5       0.99      0.98      0.99      1000

 **********6       0.79      0.75      0.77      1000

 **********7       0.95      0.99      0.97      1000

 **********8       0.99      0.98      0.99      1000

 **********9       0.98      0.96      0.97      1000


    accuracy                           0.92     10000

   macro avg       0.92      0.92      0.92     10000

weighted avg       0.92      0.92      0.92     10000

Мне не хватает в этом отчете micro avg. Как исправить вывод, чтобы добавить эту строчку?

1 ответ 1

1

Из документации:

The reported averages include macro average (averaging the unweighted mean per label), weighted average (averaging the support-weighted mean per label), sample average (only for multilabel classification)

and micro average (averaging the total true positives, false negatives and false positives) it is only shown for multi-label or multi-class with a subset of classes because it is accuracy otherwise.

See also:func: precision_recall_fscore_support for more details on averages.

Т.е. micro avg == accuracy если учитываются все классы, если же указать только подмножество классов то в выводе появится строчка с micro avg вместо accuracy.

Пример:

from sklearn.metrics import classification_report
y_true = [0, 1, 2, 2, 2]
y_pred = [0, 0, 2, 2, 1]

In [12]: print(classification_report(y_true, y_pred))
              precision    recall  f1-score   support

           0       0.50      1.00      0.67         1
           1       0.00      0.00      0.00         1
           2       1.00      0.67      0.80         3

    accuracy                           0.60         5   #  <--- NOTE !
   macro avg       0.50      0.56      0.49         5
weighted avg       0.70      0.60      0.61         5


In [13]: print(classification_report(y_true, y_pred, labels=[0, 2]))
              precision    recall  f1-score   support

           0       0.50      1.00      0.67         1
           2       1.00      0.67      0.80         3

   micro avg       0.75      0.75      0.75         4   #  <--- NOTE !
   macro avg       0.75      0.83      0.73         4
weighted avg       0.88      0.75      0.77         4

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.