0
$\begingroup$

I built a Random Forest model to classify imbalanced data (0.5% for minority class.) I used grid search to hyper tune parameters. I got the test AUC of almost 0.99. The test AUC is completely out of bag. I am not sure how we can extrapolate that this signifies overfitting?

I got some answer from https://stats.stackexchange.com/questions/333199/random-forest-has-almost-perfect-training-auc-compared-to-other-models. But I was curious about the behavior when we have imbalanced class at our desposal.

$\endgroup$
3
  • $\begingroup$ Is this out-of-bag AUC? Or training AUC? Or AUC on a completely independent data set? Are your rows dependent? $\endgroup$
    – Michael M
    Commented Jun 15, 2020 at 18:16
  • $\begingroup$ It is a completely independent dataset. I doubt that the rows are be dependent. $\endgroup$
    – Dee
    Commented Jun 15, 2020 at 18:18
  • 1
    $\begingroup$ An AUC of 98% on an independent test set for a problem where you do not feel that is possible, that would lead me to suspect some kind of test set target leakage into your training data set. $\endgroup$ Commented Jun 15, 2020 at 21:43

1 Answer 1

0
$\begingroup$

If you have a drastically imbalanced class, it is very likely that you are overfitting. Let's say that your test set comprises of 99 cases of sample A and 1 case of sample B. Then, any model you train could get "high" score, simply by classifying any value it encounters as a sample A type.

As random forest are built from decision trees which use information theory to determine which feature threshold would best partition the data, they are susceptible to imbalanced sets. This is especially true since the proportion of any one class in your dataset will affect the importance the model associates to the accurate classification of samples of this class. Intuitively, you can think that the model wants to be as right as possible, so it will focus on accurately binning (classifying) the most items.

For imbalanced testing sets, I would suggest using the F1 score to evaluate your model which is calculated as 2 * (precision * recall)/(precision + recall) to corroborate any other metrics you use (like accuracy or AUC). Additionally, I would suggest training on a balanced dataset (whether this means over sampling the minority class or undersampling the majority classes).

$\endgroup$
5
  • 1
    $\begingroup$ In your example, AUC is 0.5, which is the contrary of what is described in the OP. Furthermore, how can overfitting be the reason if the result was obtained on a completely independent data set? $\endgroup$
    – Michael M
    Commented Jun 15, 2020 at 21:21
  • $\begingroup$ If the training dataset is imbalanced, the model might just classify everything it comes across as type A. In this case, the model has over fit to one specific class, and will perform this way regardless of the data it is evaluated on. As for your first point, I was merely showing an example how imbalance could result in some funky results. $\endgroup$
    – jdjame
    Commented Jun 15, 2020 at 22:08
  • $\begingroup$ I figured the issue with my dataset. This was due to data leakage. Even though the rows are not duplicated, they are not completely independent. This is because 1 person can have multiple rows. One of the columns might vary a little but they do not change as much. So, because of this the data leaked between training and test set. @MichaelM thanks for the hint. I went back and checked everything. Now the AUC is 0.78 which looks super reasonable. $\endgroup$
    – Dee
    Commented Jun 17, 2020 at 14:15
  • $\begingroup$ Perfect, thanks for cross-checking! $\endgroup$
    – Michael M
    Commented Jun 17, 2020 at 14:26
  • $\begingroup$ How did you solve the issue of too less variability (duplicate rows) since the data is like that ? $\endgroup$
    – Gupta
    Commented Apr 1 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.