5
$\begingroup$

I am working on a fraud detection model that prevents fraudulent users from using our solution. My model is performing great but the issue I have is that the more the model becomes performant the less I have fraudulent users in my training set and hence it becomes unbalanced compared with real world data. To cope with this, we have introduced a random process that lets some users pass without being scored so that we can keep learning from unbiased data. Ideally I should train my model on this unbiased dataset only, but it is small and it's a shame not to use the big part of the data. Hence, I would like to do the following:

  1. Train my model on the whole set : scored dataset (big but biased toward good users) + unscored dataset (small but unbiased)
  2. Calibrate the probability of the model using only the unscored dataset

What do you think of this ? Can you think of any drawback or bias it would introduce ?

$\endgroup$
6
  • $\begingroup$ What metric are you using? $\endgroup$
    – spectre
    Commented Oct 8, 2021 at 11:26
  • $\begingroup$ ROC AUC and PR curve AUC $\endgroup$
    – Anatole
    Commented Oct 8, 2021 at 11:49
  • $\begingroup$ @Dave question is not really about class imbalance, but how their data compares to "real world data" $\endgroup$
    – serali
    Commented Oct 8, 2021 at 12:20
  • $\begingroup$ @Anatole I am not sure if I understand what you mean by "the more the model becomes performant the less I have fraudulent users in my training set" ? How do you update your data? $\endgroup$
    – serali
    Commented Oct 8, 2021 at 12:26
  • $\begingroup$ @serali The more the model becomes performant the more fraudulent users will be blocked from using our solution and hence they will not be part of the next training as we will never know whether they were actually fraudulent or not $\endgroup$
    – Anatole
    Commented Oct 8, 2021 at 12:51

2 Answers 2

2
$\begingroup$

There are a few things you can do. Keep in mind there are some people who would disagree with one method while others agree on the same.

1.) Since it an imbalanced dataset, you can apply any of the sampling techniques (either oversampling or undersampling). I would suggest oversampling (SMOTE) since undersampling leads to information loss. Now there are people who disagree with this method and instead advise the second method.

2.) Change the metric you are using. You should always use metrics like weighted AUC, F1 score for imbalanced datasets.

There is no clear cut winner as to which technique is right. Sampling techniques have been used by many people but on the other hand, some experts say it only introduces noise into the data and changing the metric can solve the problem.

$\endgroup$
4
  • 1
    $\begingroup$ Thanks @spectre Here my problem is not a detection problem, my model is actually performing quite well. My issue is that the weight of fraudulent cases in my training set (say 2%) is lower than the actual weight in real world (say 10%) because my model filters out most fraudulent cases. So what I am after is a method to rebalance the output probabilities of my model so that on average it finds 10% of frauds and not 2%. $\endgroup$
    – Anatole
    Commented Oct 8, 2021 at 12:18
  • $\begingroup$ Class imbalance is almost certainly not a problem, and there is no need to solve a non-problem. stats.stackexchange.com/questions/357466/… fharrell.com/post/class-damage fharrell.com/post/classification stats.stackexchange.com/a/359936/247274 stats.stackexchange.com/questions/464636/… twitter.com/f2harrell/status/1062424969366462473?lang=en $\endgroup$
    – Dave
    Commented Oct 8, 2021 at 12:33
  • $\begingroup$ I disagree. Class imbalance is frequently a very large issue, and it's easy to see how fraud would be a quintessential example of a class imbalance; the vast majority of transactions are (presumably) non fraudulent. $\endgroup$
    – Warlax56
    Commented Oct 8, 2021 at 15:40
  • $\begingroup$ @Dave That is a lot of information to go through: perhaps you could post an answer that explains the point you are making? $\endgroup$ Commented Oct 11, 2021 at 20:21
2
$\begingroup$

It is great you are thinking like this. Often when we build a model, we do not think how we will get the data for the next model build or the biases in this building model from previous models. In many models, like fraud or credit, the current model and business policy biases future data.

I have built fraud models with event rates < 1%. Personally I do not like smote type of techniques since they create data - who said that some random point between two other points should be categorized the same. I play with slight undersampling, often by weighting, to not lose too much information. Not always random undersampling but finding matches, clusters, and example transactions. And I do not always undersample.

I think the random process should be turned into a test - check out design of experiments. Then you test specifically from areas of the population to get good coverage. It is hard to test in fraud for business reasons, so like you said, your test data will be thin. You may also not want to test in certain areas that are too risky - like if your model is about financial fraud and you do not want to test where the loss may be > $10,000.

In your train/validation/holdout data sets, include some of the test data. Run specific metrics - whatever makes sense for your business problem - on the test and non-test data. Now you have some unbiased metrics and a potentially better view how the model will perform on newer data. If the test data is very thin, put it all into the holdout set.

$\endgroup$

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.