Ssawla — Published On February 16, 2023 and Last Modified On February 16th, 2023

## Introduction

Partial AUC (Area Under the Curve) scores are a valuable tool for evaluating the performance of binary classification models, particularly when the class distribution is highly imbalanced. Unlike traditional AUC scores, partial AUC scores concentrate on a specific region of the ROC (Receiver Operating Characteristic) curve, offering a more detailed evaluation of the model’s performance.

This blog post will dive into what partial AUC scores are, how they are calculated, and why they are essential for evaluating imbalanced datasets. We will also include relevant examples and a code example using Python to help make these concepts clearer.

Learning Objectives:

1. Learning the basics of AUC Scores.
2. What are the disadvantages of AUC Scores, and how to overcome them?
3. How to calculate partial scores and their objective.

This article was published as a part of the Data Science Blogathon.

## What do AUC Scores Mean?

AUC (Area Under the Curve) scores are a commonly used metric for evaluating the performance of binary classification models. The traditional AUC score calculates the area under the ROC (Receiver Operating Characteristic) curve, which plots the True Positive Rate (TPR) against the False Positive Rate (FPR) for all possible threshold values. The score ranges from 0.5 for a random model to 1 for a perfect model, with values closer to 1 indicating better performance.

## The Drawback of AUC Scores

However, in real-world applications, the class distribution of the target variable can be highly imbalanced, meaning that one class is much more prevalent than the other. In these cases, the traditional AUC score may not provide a good evaluation of the model’s performance as it aggregates the performance overall threshold values and does not account for the imbalance in the class distribution.

## Overcoming the Drawback

This is where partial AUC scores come into play. Unlike traditional AUC scores, they focus on a specific region of the ROC curve, providing a more granular evaluation of the model’s performance. This allows for a more accurate evaluation of the model’s performance, especially in cases where the class distribution is highly imbalanced.

For example, in a fraud detection problem, the partial AUC score can be calculated for the region where the FPR is less than a specific value, such as 0.05. This provides an evaluation of the model’s performance at catching fraud instances while ignoring the performance on the majority class instances. This information can be used to make informed decisions about which models to use, how to improve models, and how to adjust the threshold values for predictions.

## Calculating Partial AUC Scores

Calculating partial AUC scores involves dividing the ROC curve into intervals and then computing the AUC for each interval. The intervals can be defined in terms of the FPR or TPR, and the size of the intervals can be adjusted to control the granularity of the evaluation. The partial AUC score for a specific interval is calculated as the sum of the areas of the rectangles formed by the interval boundaries and the ROC curve within that interval.

For example, to calculate the partial AUC score for the region where the FPR is less than 0.05,

1. we would first divide the ROC curve into intervals for the specific interval where the FPR is less than 0.05.
2. Then, we would calculate the sum of the areas of the rectangles formed by the interval boundaries and the ROC curve within that interval. This would give us the partial AUC score for that region.

In addition to the fraud detection example, partial AUC scores can be used in a variety of other real-world applications such as medical diagnosis, credit scoring, and marketing.

1. In medical diagnosis, they can be used to evaluate the performance of a model in detecting a specific disease while ignoring its performance on healthy individuals.
2. In credit scoring, they can be used to evaluate the performance of a model in detecting high-risk loan applicants while ignoring its performance on low-risk loan applicants.
3. In marketing, they can be used to evaluate the performance of a model in predicting which customers are most likely to purchase while ignoring its performance on customers who are unlikely to make a purchase.

In conclusion, partial AUC scores are an important tool for evaluating the performance of binary classification models, especially in cases where the class distribution is highly imbalanced. By focusing on a specific region of the ROC curve, partial AUC scores provide a more granular evaluation of the model’s performance, which can be used to make informed decisions about model selection, improvement, and threshold adjustment. Understanding them and how to use them is an important part of the evaluation process for binary classification models and can lead to more accurate and effective decision-making in various real-world applications.

It’s important to note that partial AUC scores are not a replacement for traditional AUC scores but rather a complementary tool to be used in conjunction with traditional AUC scores. While they provide a more nuanced evaluation of the model’s performance in specific regions of the ROC curve, traditional AUC scores provide a more holistic evaluation of the model’s overall performance.

When evaluating binary classification models, it’s best to use both traditional AUC scores and partial AUC scores to get a complete picture of the model’s performance. This can be done by plotting the ROC curve and calculating both the traditional AUC score and the partial AUC scores for specific regions of the curve.

## Partial AUC Scores in Python

Now, let’s see how to calculate partial AUC scores in Python. The easiest way to calculate partial AUC scores in Python is by using the “roc_auc_score” function from the scikit-learn library. This function calculates the traditional AUC score by default, but it can also be used to calculate partial AUC scores by passing in the “curve” parameter.

For example, let’s say we have a binary classification model and its predictions on the test data. We can use the following code to calculate the traditional AUC score:

``````from sklearn.metrics import roc_auc_score

y_true = [0, 0, 1, 1]

y_scores = [0.1, 0.4, 0.35, 0.8]

auc = roc_auc_score(y_true, y_scores)

print('AUC:', auc)``````

To calculate the partial AUC score for the region where the FPR is less than 0.05, we can pass in the “max_fpr” parameter as follows

```from sklearn.metrics import roc_auc_score
y_true = [0, 0, 1, 1]
y_scores = [0.1, 0.4, 0.35, 0.8]
auc = roc_auc_score(y_true, y_scores, max_fpr=0.05)
print('Partial AUC:', auc)```

## Conclusion

In summary, it provides a more granular evaluation of the performance of binary classification models, especially in cases where the class distribution is highly imbalanced. Understanding and using them can greatly enhance the evaluation of binary classification models in imbalanced datasets.

• By combining traditional AUC and partial AUC scores, we can get a complete picture of the model’s performance and make informed decisions about model selection, improvement, and threshold adjustment.
• With the help of Python’s scikit-learn library, calculating partial AUC scores is a straightforward and convenient process.
• When evaluating binary classification models, it’s best to use both traditional AUC scores and partial AUC scores to get a complete picture of the model’s performance.