2
$\begingroup$

I have just begun learning about machine learning techniques and started solving problems on kaggle. I have a few questions about how to handle class imbalance:

  1. How to handle imbalance dataset apart from SMOTE?
  2. In Kaggle can we balance data by merging train and test csv file and resample?
  3. If yes, then How to resample in that case? Are there any other suggestions?
$\endgroup$
0
$\begingroup$

Handling Imbalanced datasets is broad subject. In general, more than one methods are used to deal with this situation (at least applying all possible methods and comparing them to find the best possible approach is the best practice).

Popular methods are SMOTE and ADASYN. They may be practiced as a good starting point.

Please find the below article as a good starting points for the general background.

https://medium.com/james-blogs/handling-imbalanced-data-in-classification-problems-7de598c1059f

"Imbalanced data set occurs when there is unequal representation of classes. In certain areas such as fraud detection, medical diagnosis and risk management, severe imbalance class distribution is relatively common, and therefore, is a concerning problem. There are 3 main problems imposed by data with unequal class distributions, The machine problem, The intrinsic problem and the human problem.

There has been two different approaches to addressing imbalanced data: algorithm-level and data-level approach.

Data approach consist of re-sampling the data in order to mitigate the effect caused by class imbalance. The two common technique is over-sampling and under-sampling. In over-sampling techniques such as SMOTE over-sampling or ADASYN over-sampling may be applied to dataset.

In python there is a library called imbalanced-learn: https://imbalanced-learn.readthedocs.io/en/stable/index.html

"imbalanced-learn is a python package offering a number of re-sampling techniques commonly used in datasets showing strong between-class imbalance. It is compatible with scikit-learn and is part of scikit-learn-contrib projects."

For your other questions (#2 and #3), the simple answer is you should not do that. If you merge train and test set and apply any method to reduce imbalance between classes you will bias your models. It is explained in below:

https://datascience.stackexchange.com/questions/47228/using-smote-for-synthetic-data-generation-to-improve-performance-on-unbalanced-d

First of all, you have to split your data set into train/test splits before doing any over/under sampling. If you do any strategy based on your approaches, and then split data you will bias your model and that is wrong simply because you are introducing points on your future test set that does not exist and your scores estimations would be imperfect.

$\endgroup$
  • $\begingroup$ Welcome to the site, @ugurcaliskan. This is a nice contribution. It seems to address the OP's first question. Can you address #2 & 3 as well? $\endgroup$ – gung Mar 13 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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