In [1]:
from sklearn.metrics import classification_report
import pandas as pd
import pprint
In [2]:
y_true = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
y_pred = [0, 1, 1, 1, 1, 0, 0, 0, 1, 1]
In [3]:
print(classification_report(y_true, y_pred))
In [4]:
print(type(classification_report(y_true, y_pred)))
In [5]:
print(classification_report(y_true, y_pred,
target_names=['class_0', 'class_1']))
In [6]:
d = classification_report(y_true, y_pred, output_dict=True)
In [7]:
pprint.pprint(d)
In [8]:
print(d['0'])
In [9]:
print(d['0']['precision'])
In [10]:
print(type(d['0']['precision']))
In [11]:
df = pd.DataFrame(d)
In [12]:
print(df)
In [13]:
print(df.iloc[:, :-3])
In [14]:
print(df.iloc[:, -3:])