In the context of machine learning, an imbalanced classification problem states to a dataset in which the classes are not evenly distributed. This problem commonly occurs when attempting to classify data in which the distribution of labels or classes is not uniform. Using resampling methods to accumulate samples or entries from the minority class or to drop those from the majority class can be considered the best solution to this problem. The focus of this study is to propose a framework pattern to handle any imbalance dataset for fraud detection. For this purpose, Undersampling (Random and NearMiss) and oversampling (Random, SMOTE, BorderLine SMOTE) were used as resampling techniques for the concentration of our experiments for balancing an evaluated dataset. For the first time, a large-scale unbalanced dataset collected from the Kaggle website was used to test both methods for detecting fraud in the Tunisian company for electricity and gas consumption. It was also evaluated with four machine learning classifiers: Logistic Regression (LR), Naïve Bayes (NB), Random Forest, and XGBoost. Standard evaluation metrics like precision, recall, F1-score, and accuracy have been used to assess the findings. The experimental results clearly revealed that the RF model provided the best performance and outperformed all other matched classifiers with attained a classification accuracy of 89% using NearMiss undersampling and 99% using Random oversampling.
Credit risk assessment under severe class imbalance requires both structured imbalance correction and principled decision rules, yet most studies treat these as independent steps. This study develops a general integrated three-layer framework for credit risk assessment under class imbalance. The first layer introduces Sequential Hybrid Data Oversampling (SHDO), which sequentially applies five complementary oversampling techniques to enrich minority-class representation in mixed-type credit data. The second layer formulates credit approval as a decision-theoretic optimisation problem: a closed-form optimal threshold is derived under asymmetric costs, extended to constrained portfolios via a Lagrangian formulation with Karush–Kuhn–Tucker conditions, and further extended to minimax-robust decision making under estimation uncertainty. The third layer compares eleven classifiers under a unified evaluation protocol with an ablation isolating the effect of SHDO. The framework is empirically validated on the Home Credit Default Risk dataset, which is used as an illustrative case study rather than defining the scope of the contribution. On the held-out test set, XGBoost trained with SHDO achieves the highest minority-class F1 (0.254), while gradient-boosted models collectively attain ROC-AUC values of 0.713–0.750, outperforming classical baselines (0.540–0.620). The ablation confirms that without SHDO, all models exhibit near-zero minority-class recall despite adequate ranking ability. SHAP analysis on XGBoost confirms that the learned risk structure aligns with established creditworthiness determinants. The decision framework converts these probability estimates into analytically justified approval thresholds responsive to economic parameters, institutional constraints, and estimation uncertainty.