# PR AUC

## What is Precision-Recall AUC?

In machine learning, we use the precision-recall AUC (area under the curve) as a performance measurement for [binary classification](/content/glossary/binary-classification/index.html) problems. This metric amalgamates two significant measurements: [precision](/content/glossary/average-precision/index.html) (which gauges positive prediction accuracy) and [recall](/content/glossary/recall-in-machine-learning/index.html) (an indicator of how effectively our model detects the positive class). The PR curve plots the precision (y-axis) against the recall (x-axis) for different threshold values. The area under the precision-recall curves, termed PR AUC, quantifies a single measure of performance: the model’s capacity to differentiate between classes across all thresholds. This is especially valuable in evaluating models on [imbalanced datasets](/content/glossary/imbalanced-data/index.html).

## How to Calculate PR AUC?

To calculate PR curve, one must focus on generating the precision-recall curve and subsequently compute the area under this curve. Several steps are involved in that process. Utilizing the trapezoidal rule – a method that approximates by summing areas of trapezoids formed beneath a given plot or chart – allows for an efficient AUC calculation. The AUC formula used in this specific computation is as follows:

- Sort predictions by their probability scores in descending order.
- For each threshold, calculate precision and recall values.
- Plot these values to form the precision-recall curve.
- Employ numerical integration to compute the area beneath the precision-recall curve.

## Benefits of PR AUC

- **The holistic performance metric:** A comprehensive view of the model’s performance across all classification thresholds by combining precision and recall. This robust metric proves effective for binary classification problems; it captures the crucial trade-off between maximizing positive captures and sustaining high precision – an essential element in numerous practical applications.
- **Sensitive to [class imbalance](/content/glossary/class-imbalance/index.html):** PR AUC values demonstrate its worth in scenarios characterized by a significant class imbalance; it concentrates on the model’s performance in predicting the minority class and that way it offers invaluable metrics for applications such as fraud detection or rare disease identification. In these instances, positive occurrences are notably less frequent than negative ones.
- **Practical for comparing models:** A single value offering an efficient method of comparing various model performances proves particularly useful in the selection process for models. This streamlined evaluation approach accelerates the identification of the most effective model; it is especially advantageous when confronting significant numbers of potential candidates within machine learning pipelines.

## Limitations of PR AUC

- **Not intuitive:** Those unfamiliar with precision and recall metrics may find the interpretation of PR AUC values less intuitive than other metrics, such as [accuracy](/content/glossary/machine-learning-model-accuracy/index.html). This lack of intuitiveness can oblige further training or explanation for stakeholders to fully grasp how these values affect model performance.
- **Dependent on class distribution:** The performance and interpretation of PR AUC can vary with changes in class distribution: this reliance on the class distribution renders it less reliable for datasets where an anticipated shift in this factor is expected over time. Consequently, analysts must carefully consider their dataset’s current composition – as well as its projected future makeup – when employing PR AUC for model evaluation. This variability demands a judicious approach.
- **No direct relation to accuracy:** PR AUC, focusing on the positive class, does not directly account for true negatives. However, in some contexts, this can be a crucial aspect of overall model performance. The limitation underscores that we must approach model evaluation multifariously by combining PR AUC with other metrics that measure the ability to correctly identify negative instances.

## PR AUC vs ROC AUC

Popular metrics for evaluating binary classification models include PR AUC and ROC AUC, but they emphasize distinct facets of model performance:

- ROC AUC plots the true positive rate (recall) against the false positive rate at various threshold settings, providing a measure of a model’s ability to distinguish between the classes at different levels of false positive rates.
- On the other hand, PR AUC provides more informative results for datasets exhibiting a significant class imbalance; it squarely focuses on the model’s ability to identify the positive class without erroneously categorizing negative instances as positive.

The specific task requirements – such as the cost of false positives, the dataset’s class distribution, and the importance attached to detecting the positive class – determine whether one should choose PR AUC or ROC AUC.
