Classification Report in Machine Learning

A classification report is a performance evaluation metric in machine learning. It is used to show the precision, recall, F1 Score, and support of your trained classification model. If you have never used it before to evaluate the performance of your model then this article is for you. In this article, I will take you through an introduction to the classification report in machine learning and its implementation using Python.

Classification Report

It is one of the performance evaluation metrics of a classification-based machine learning model. It displays your model’s precision, recall, F1 score and support. It provides a better understanding of the overall performance of our trained model. To understand the classification report of a machine learning model, you need to know all of the metrics displayed in the report. For a clear understanding, I have explained all of the metrics below so that you can easily understand the classification report of your machine learning model:

MetricsDefinition
Precision Precision is defined as the ratio of true positives to the sum of true and false positives.
Recall Recall is defined as the ratio of true positives to the sum of true positives and false negatives.
F1 Score The F1 is the weighted harmonic mean of precision and recall. The closer the value of the F1 score is to 1.0, the better the expected performance of the model is.
Support Support is the number of actual occurrences of the class in the dataset. It doesn’t vary between models, it just diagnoses the performance evaluation process.

Hope you now understand what a classification report is in machine learning. Now in the section below, I will walk you through its implementation using Python.

Classification Report using Python

To view the classification report of a machine learning model, we must first train a machine learning model. In the code below, I first trained a very simple machine learning model to classify spam messages and to evaluate its performance I have used a classification report using Python:

              precision    recall  f1-score   support

         ham       0.99      0.99      0.99      1587
        spam       0.93      0.92      0.92       252

    accuracy                           0.98      1839
   macro avg       0.96      0.95      0.96      1839
weighted avg       0.98      0.98      0.98      1839

Summary

So this is how you can display the classification report of your machine learning model. It is a performance evaluation metric in machine learning which is used to show the precision, recall, F1 Score, and support score of your trained classification model. I hope you liked this article on what is a classification report in machine learning and its implementation using Python. Feel free to ask your valuable questions in the comments section below.

Aman Kharwal
Aman Kharwal

I'm a writer and data scientist on a mission to educate others about the incredible power of data📈.

Articles: 1537

2 Comments

  1. Dear Aman Kharwal,

    The service you are rendering is really GREAT. Thanks you very much. I am a Professor in Management discipline. I couldn’t find a better source than this. Now I am confident that I can learn Machine Learning over a period of time. BRAVO !
    – Prof.Jagadish Reddy

Leave a Reply