Evaluating a classification model

Earlier in this chapter, we have discussed five different ways to look at the performance of a classification model. In this section, we are going to learn how we can compute and visualize the metrics for evaluating a classification model in Python using the random forest model we have just built.

The first three metrics that we are going to look at are accuracy, precision, and recall. Python's scikit-learn package has implemented functions for these three metrics. You can import these functions using the following line of code:

from sklearn.metrics import accuracy_score, precision_score, recall_score

As you can see from this code snippet, the metrics module of the scikit-learn package has an accuracy_score ...

Get Hands-On Data Science for Marketing 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.