Global classification report

scikit-learn provides a helpful built-in function to generate a global classification report based on the most common evaluation metrics. This is an example using binary logistic regression:

from sklearn.metrics import classification_reportprint(classification_report(Y_test, lr.predict(X_test)))              precision recall  f1-score support0             0.98     0.95     0.97     631             0.95     0.98     0.97     62avg / total   0.97     0.97     0.97     125

The first column represents the classes and, for each of them, precision, recall, f1-score, and support (number of assigned samples) are computed. The last row shows the average values corresponding to every column. I highly recommend this function instead of the single metrics because of its compactness and completeness. ...

Get Machine Learning Algorithms - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.