Member-only story
A classification report is a goodness of fit indicator in machine learning. This report shows the main classification metrics used in a classification problem.
Python’s machine learning library, sklearn, has a classification report function that can be used when making predictions on classification datasets:- https://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html
This report utilises three common metrics to reflect how well the model was able to make predictions. These three metrics in the classification report are:-
- Precision,
- Recall, and
- F1 score.
Precision relates to the correct positive predictions relative to the total positive predictions.
Recall is represented as the percentage of correct positive predictions relative to actual total positives.
The F1 score is a weighted harmonic mean of precision and recall.
Python code for how to implement the sklearn’s classification report can be seen below:-
Of course, it is also possible to create your own classification report from the values returned from sklearn’s confusion matrix, as seen below:-
The classification report, along with the confusion matrix, will show how well a machine learning model is performing. When dealing with a class imbalance, it is not always a good idea to rely solely on the accuracy readings alone.