3

I am using Sklean's classification_report to summarize my train and test epochs.

sklearn.metrics.classification_report

I'm getting kind of this back for each epoch:

>>> from sklearn.metrics import classification_report
>>> y_true
>>> y_pred 
>>> target_names = ['class 0', 'class 1', 'class 2']
>>> print(classification_report(y_true, y_pred, target_names=target_names))
              precision    recall  f1-score   support

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

    accuracy                           0.60         5
   macro avg       0.50      0.56      0.49         5
weighted avg       0.70      0.60      0.61         5

(e.g. from sklearn script)

Now I am searching for a way, to get those accuracy for each epoch in a list to calculate the mean and std of all accuracy.

This question seems to be pretty trivial but as you can see from my questions before I am pretty new to Python/Machine Learning.

Thanks for your help

Leo

Prashant
  • 394
  • 1
  • 6
  • 18
VomDorfe
  • 51
  • 2
  • 5

1 Answers1

9

Lets have a look at the documentation which contains information about the input parameter output_dict :

output_dict : bool (default = False) If True, return output as dict

If you call classification_report(y_true, y_pred, target_names=target_names, output_dict=True) you can get the dictionary. And then you are one stackoverflow question away from your solution.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Nikolas Rieble
  • 2,416
  • 20
  • 43