1. Learn
  2. /
  3. Courses
  4. /
  5. Marketing Analytics: Predicting Customer Churn in Python

Exercise

Computing precision and recall

The sklearn.metrics submodule has many functions that allow you to easily calculate interesting metrics. So far, you've calculated precision and recall by hand - this is important while you develop your intuition for both these metrics.

In practice, once you do, you can leverage the precision_score and recall_score functions that automatically compute precision and recall, respectively. Both work similarly to other functions in sklearn.metrics - they accept 2 arguments: the first is the actual labels (y_test), and the second is the predicted labels (y_pred).

Let's now try a training size of 90%.

Instructions 1/3

undefined XP
    1
    2
    3
  • Import precision_score from sklearn.metrics.