Getting the accuracy from classification_report back into a list
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:

&gt;&gt;&gt; from sklearn.metrics import classification_report
&gt;&gt;&gt; y_true
&gt;&gt;&gt; y_pred 
&gt;&gt;&gt; target_names = ['class 0', 'class 1', 'class 2']
&gt;&gt;&gt; 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

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.
