I have a data set where I need to detect fraud. 99% are not fraud and 1% are.
What methods can be used to solve problems where classes are imbalanced?
I have a data set where I need to detect fraud. 99% are not fraud and 1% are.
What methods can be used to solve problems where classes are imbalanced?
There are 2 Techniques:
Oversampling: There are many techniques under this, ROSE and SMOTE are the most famous techniques used for oversampling. In ROSE it just increases the minority classes. In SMOTE it synthetically generates more number of rare minority classes for balancing. Most of the Scenarios SMOTE gives better results than ROSE but you should try both. Other than that there is just another techniques which just duplicates the records to the make it equal n number. This Link, is for implemenation of SMOTE in Python.
UnderSampling: There are many techniques under this too, but this Link-1, Link-2 gives you better idea about undersampling. Generally I don't prefer Undersampling, as you would loose some infomation.
The reason why you need to use these techniques are, if we don't use then the model accuracy will be very high it will be able to predict with 99% accuracy correctly the cases which are not fraud, which we don't want. if it can predict with same accuracy to find out fraud, then that is a great insight. This can be achived only by using either of the above techniques.
Do have a look and Let me know if you have any additional questions.
There are several techniques
Random up-sampling
Random Down-Sampling
Repeated Sampling
You can use some related parameters as cost function such as Kappa
, CEN
, and MCEN
in all types of algorithms.
Disclaimer:
If you are using Python you can use PyCM module. This module after receiving the confusion matrix of your data can suggest some parameters which is suitable for evaluating your algorithm according to the characteristics of your dataset.
Here is a simple code to get the recommended parameters from this module:
>>> from pycm import *
>>> cm = ConfusionMatrix(matrix={"Class1": {"Class1": 1, "Class2":2}, "Class2": {"Class1": 0, "Class2": 5}})
>>> print(cm.recommended_list)
["Kappa", "SOA1(Landis & Koch)", "SOA2(Fleiss)", "SOA3(Altman)", "SOA4(Cicchetti)", "CEN", "MCEN", "MCC", "J", "Overall J", "Overall MCC", "Overall CEN", "Overall MCEN", "AUC", "AUCI", "G", "DP", "DPI", "GI"]
You can do following the two approaches.