The ROC Curve Myth for Imbalanced Datasets


Welcome!

Every Monday, I’ll drop a no-fluff, straight-to-the-point tip on a data science skill, tool, or
method to help you stay sharp in the field. I hope you find it useful!


The ROC Curve Myth for Imbalanced Datasets

One myth I hear far too often is that the ROC curve is not a good metric for evaluating models trained on imbalanced datasets because it tends to produce overly optimistic ROC-AUC values.

This is not true. Last Monday we saw that ROC curves are insensitive to class prevalence: same model, different class prevalence = same ROC-AUC.

Today, we’ll debunk the myth that ROC-curves are overly optimistic.

ROC-Curves reflect the ability of the model to separate the classes correctly

While writing my new book Imbalanced Data: Myths, Mistakes and Modern Solutions I ran several experiments, many to debunk common myths about working with imbalance data, and many others to put undersampling and oversampling to the test.

Today, I’ll show you that this myth, that the ROC-curve is overly optimistic, is false.

I trained several ensemble models, including random forests, XGBoost, Catboost and lightGBM across 37 datasets with different degrees of class imbalance, and evaluated them using ROC-curves. Here’s what I saw.

For many datasets, I found ROC curves close to the top-left corner of the plot with AUC values close to 1. However, this behaviour was far from universal.

Take a look at the following figure. Some datasets (e.g., car_eval_4 and protein_homo) produce near-perfect ROC curves, whereas others (e.g., coil_2000 and scene) yield much lower AUC values despite being imbalanced:

The shape of the ROC curve therefore reflects how well the model separates the classes, not the prevalence of the minority class.

High ROC-AUC values, like those observed for the protein homology dataset, were not an artefact of class imbalance. Instead, they reflected that the model genuinely achieved strong class separation.

To investigate further, I plotted pairwise combinations of six features from the protein homology dataset, colouring observations according to their class label.

Take a look at the following image now. In most panels, the red and blue points occupy distinct regions of the feature space, with only limited overlap.

This indicates that the classes are already well separated by the original features, making the prediction task inherently easier and explaining why most models achieve ROC-AUC values close to one.

So bottom line: ROC curves are not overly optimistic by default. Instead, the truly reflect the capacity of the model to discriminate among classes.

Hence, if your models achieve a high ROC-AUC, that’s something to be happy about rather than worry over.

If you liked this article, consider supporting me by buying my new book: Imbalanced Data: Myths, Mistakes and Modern Solutions.

I hope this information was useful!

Wishing you a successful week ahead - see you next Monday! 👋🏻

Sole


Ready to enhance your skills?

Our specializations, courses and books are here to assist you:


Hi…I’m Sole
​
I’m the main instructor at Train in Data. My work as a data scientist includes creating and implementing machine learning models for evaluating insurance claims, managing credit risk, and detecting fraud. In 2018, I was honoured with a Data Science Leaders' award, and in 2019 and again in 2024, I was acknowledged as one of LinkedIn's voices in data science and analytics.

You are receiving this email because you subscribed to our newsletter, signed up on our website, purchased or downloaded any products from us.


Follow us on social media

Copyright (C) 2026 Train in Data. All rights reserved.

​
​Unsubscribe · Preferences​

Train in Data

by Soledad Galli, PhD | Data scientist | Python Developer | Best-selling instructor | Book author | 👉 www.trainindata.com

Read more from Train in Data
Which hyperparameters should you tune?

Welcome! Every Monday, I’ll drop a no-fluff, straight-to-the-point tip on a data science skill, tool, ormethod to help you stay sharp in the field. I hope you find it useful! Which hyperparameters should you tune? Anyone who opens the XGBoost documentation for the first time finds a long list of hyperparameters, from the learning rate and the depth of the trees to regularisation terms, sampling ratios and a few options whose purpose is far from obvious. Faced with that list, it is hard to...

Job descriptions rarely tell the whole story

Welcome! Every Monday, I’ll drop a no-fluff, straight-to-the-point tip on a data science skill, tool, ormethod to help you stay sharp in the field. I hope you find it useful! New set of focused ML interpretability courses now on Udemy I know many of you already use Udemy, so this October I released a new series of short, focused courses designed to help you learn one valuable machine learning skill at a time The Complete SHAP and Shapley Values Masterclass Interpretable Machine Learning:...

AI-generated pull requests won't land you that data science job

Welcome! Every Monday, I’ll drop a no-fluff, straight-to-the-point tip on a data science skill, tool, ormethod to help you stay sharp in the field. I hope you find it useful! Three proof copies of my books looking for a new home While I was working on making the physical copies of my books available through different providers, I ended up with three proof copies. They are not perfect: one has the "not for sale" band, and one of the feature selection copies has a few typos here and there....