- Python Machine Learning Cookbook(Second Edition)
- Giuseppe Ciaburro Prateek Joshi
- 95字
- 2021-06-24 15:40:49
How to do it…
Let's see how to extract a performance report:
- Add the following lines to a new Python file (load the performance_report.py file):
from sklearn.metrics import classification_report
y_true = [1, 0, 0, 2, 1, 0, 3, 3, 3]
y_pred = [1, 1, 0, 2, 1, 0, 1, 3, 3]
target_names = ['Class-0', 'Class-1', 'Class-2', 'Class-3']
print(classification_report(y_true, y_pred, target_names=target_names))
- If you run this code, you will see the following on your Terminal:
Instead of computing these metrics separately, you can directly use the preceding function to extract those statistics from your model.