Classification Report (Python Model Evaluation)

classification report python

Classification report is used to evaluate a model’s predictive power. It is one of the most critical step in machine learning.

After you have trained and fitted your machine learning model it is important to evaluate the model’s performance.

One way to do this is by using sklearn’s classification report.

It provides the following that will help in evaluating the model :

  • Precision
  • Recall
  • F1-score
  • Support

The first step is importing the classification_report library.

from sklearn.metrics import classification_report

Once the library has been imported you can now run the classification report with this Python command:


y_test the dependent variable from your test data set. (train-test split of data) 

predictions is the data output of your model.

Make sure that the exact arrangement where y_test variable comes before predictions variable in the Python code is followed.

If not the it will give a wrong model performance which will lead to a wrong evaluation.

Here is a sample output for classification_report:

You can see here that on average the model has predicted 85% of the classification correctly.

For Class 0.0 it has predicted 86% of the test data correctly.

Classification_report is also useful when comparing two models with different specifications against each other and determining which model is better to use.

For more details visit the official sklearn documentation:


Please enter your comment!
Please enter your name here