imbalanced-learn

Toolbox for handling imbalanced datasets in machine learning

pipmacoslinuxwindows
Try with needOr install directly
Source

About

Toolbox for imbalanced dataset in machine learning

Commands

imbalanced-learn

Examples

Import and use SMOTE for oversampling minority class$ python -c "from imblearn.over_sampling import SMOTE; smote = SMOTE(); X_resampled, y_resampled = smote.fit_resample(X, y)"
Apply RandomUnderSampler to balance dataset classes$ python -c "from imblearn.under_sampling import RandomUnderSampler; rus = RandomUnderSampler(); X_resampled, y_resampled = rus.fit_resample(X, y)"
Create pipeline combining preprocessing and classification$ python -c "from imblearn.pipeline import Pipeline; from imblearn.over_sampling import SMOTE; from sklearn.ensemble import RandomForestClassifier; pipe = Pipeline([('smote', SMOTE()), ('clf', RandomForestClassifier())])"