If you face imbalance data in your machine learning project, this package is here to pre-process your data. It is an efficient and ready-to-use implementation of MGS-GRF, an oversampling strategy designed to handle large-scale and mixed imbalanced data-set — with both continuous and categorical features.
The MGS-GRF package is supported by two peer-reviewed publications:
A paper at AISTATS 2026 introducing the algorithm for continuous input: Do we need rebalancing strategies? A theoretical and empirical study around SMOTE and its variants 📄
A paper at ECML-PKDD 2025 presenting the extension of MG to categorical features (MGS-GRF): Harnessing Mixed Features for Imbalance Data Oversampling: Application to Bank Customers Scoring 📄
🛠 Installation
From Pypi:
pip install mgs-grf
From source:
git clone git@github.com:artefactory/mgs-grf.git
And install the required packages into your environment (conda, mamba or pip):
pip install -r requirements.txt
💻 How to use the MGS-GRF Algorithm to learn on imbalanced data
Here is a short example on how to use MGS-GRF:
from mgs_grf import MGSGRFOverSampler
## Apply MGS-GRF procedure to oversample the data
mgs_grf = MGSGRFOverSampler(categorical_features=categorical_features, random_state=0)
X_train_balanced, y_train_balanced = mgs_grf.fit_resample(X_train_imbalanced, y_train_imbalanced)
## Encode the categorical variables
enc = OneHotEncoder(handle_unknown="ignore", sparse_output=False)
X_train_balanced_enc = np.hstack((X_train_balanced[:,numeric_features],
enc.fit_transform(X_train_balanced[:,categorical_features])))
X_test_enc = np.hstack((X_test[:,numeric_features], enc.transform(X_test[:,categorical_features])))
# Fit the final classifier on the augmented data
clf = lgb.LGBMClassifier(n_estimators=100, verbosity=-1, random_state=0)
clf.fit(X_train_balanced_enc, y_train_balanced)
A more detailed notebook example is available in this notebook.
🙏 Acknowledgements
This work was done through a partenership between Artefact Research Center and the Laboratoire de Probabilités Statistiques et Modélisation (LPSM) of Sorbonne University.
📜 Citation
If you find the code useful, please consider citing us :
@inproceedings{sakho2024we,
title={Do we need rebalancing strategies? A theoretical and empirical study around SMOTE and its variants},
author={Sakho, Abdoulaye and Malherbe, Emmanuel and Scornet, Erwan},
booktitle={The 29th International Conference on Artificial Intelligence and Statistics},
year={2026},
organization={PMLR}
}
@inproceedings{sakho2025harnessing,
title={Harnessing Mixed Features for Imbalance Data Oversampling: Application to Bank Customers Scoring},
author={Sakho, Abdoulaye and Malherbe, Emmanuel and Gauthier, Carl-Erik and Scornet, Erwan},
booktitle={Joint European Conference on Machine Learning and Knowledge Discovery in Databases},
pages={247--264},
year={2025},
organization={Springer}
}
Metadata
Release files for mgs-grf 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mgs_grf-0.1.0.tar.gz | 15.3 kB | Without provenance | Details for mgs_grf-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mgs_grf-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mgs_grf-0.1.0-py3-none-any.whl |
Total release size: 27.6 kB
Release files / mgs_grf-0.1.0.tar.gz
| Download URL | mgs_grf-0.1.0.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30952f5c24bd07b58b078823aed1efb4d99c994ae601e91959cff0dbd53867dc
|
|
BLAKE2b-256 checksum How to use checksums |
0558d3937aec0efacd14df038924c8628591f08841ef57abd56fdfb22a8177ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / mgs_grf-0.1.0-py3-none-any.whl
| Download URL | mgs_grf-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f09fa6aa5e49d429d6ac75716e66d33bd5d29c6556cda17c13c61be329b2150
|
|
BLAKE2b-256 checksum How to use checksums |
bacd773ad6e4c483812020c10454f2215111cc0b6256b503cbe65904b80cd232
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Security for mgs-grf 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.