Fix Imbalance in Target Variable


When dataset has unequal distribution of target class it can be fixed using fix_imbalance parameter. When set to True, SMOTE (Synthetic Minority Over-sampling Technique) is applied by default to create synthetic datapoints for minority class.  Method for resampling can be changed using fix_imbalance_method parameter within setup.

This is only available in pycaret.classification.

 

Parameters in setup 


fix_imbalance: bool, default = False
When dataset has unequal distribution of target class it can be fixed using fix_imbalance parameter. When set to True, SMOTE (Synthetic Minority Over-sampling Technique) is applied by default to create synthetic datapoints for minority class.

fix_imbalance_method: obj, default = None
When fix_imbalance is set to True and fix_imbalance_method is None, ‘smote’ is applied by default to oversample minority class during cross validation. This parameter accepts any module from ‘imblearn’ that supports ‘fit_resample’ method.

 

How to use?


 

# Importing dataset
from pycaret.datasets import get_data
credit = get_data('credit')

# Importing module and initializing setup
from pycaret.classification import *
clf1 = setup(data = credit, target = 'default', fix_imbalance = True)

 

Was this page helpful?

Send feedback