Getting Started

What is Precision in Machine Learning?

What is Precision in Machine Learning?

Precision is defined as the ratio of true positive predictions to the total number of positive predictions made by the model. In simple terms, it tells us how many of the items the model identified as relevant are actually relevant. It’s calculated using the following formula:

$$ \text{Precision} = \frac{\text{True Positives}}{\text{True Positives} + \text{False Positives}} $$

  • True Positives (TP): Cases where the model correctly predicts a relevant item.
  • False Positives (FP): Cases where the model incorrectly predicts an item as relevant when it is not.

Let’s take a closer look at an example.

Example of Precision

Imagine an ecommerce platform that recommends products based on a customer’s past purchases and browsing history. Let’s say a model predicts 50 products as relevant to a specific user, and out of these, 40 products genuinely match the user’s interests (True Positives), while 10 products do not (False Positives).

The precision of this recommendation model would be:

$$ \text{Precision}=\frac{40}{40 + 10}= \frac{40}{50}=0.8(80\%) $$

This means 80% of the recommended products are genuinely relevant to the user’s preferences, giving us an indication of the model’s effectiveness in filtering out irrelevant items.

Precision vs. Recall

Precision is often discussed alongside recall. While precision focuses on the accuracy of positive predictions, recall measures how well the model captures all relevant items. Depending on the use case, we may prioritize one over the other:

  • High Precision, Low Recall: Useful when the cost of false positives is high, and we only want to recommend items we’re very confident in.
  • High Recall, Low Precision: Useful when we want to capture as many relevant items as possible, even if some are false positives.

In many applications, a balance between precision and recall is desired, which is why the F1 score is used. The F1 score is the harmonic mean of precision and recall, providing a single metric that balances both.

Conclusion

Precision is a fundamental metric in machine learning that provides insight into the accuracy of a model’s positive predictions. In domains like ecommerce, precision directly impacts user satisfaction by helping ensure that recommendations are relevant. While it’s not the only metric used to evaluate models, precision is crucial for applications where false positives need to be minimized.

Ellie Sleightholm
Head of Developer Relations at Marqo