It's not uncommon to encounter overfitting when working with imbalanced datasets, but there are a few techniques you can try to mitigate this issue. Here are some suggestions from my personal experience:
-Hyperparameter tuning: Perform a systematic search for the best hyperparameters for your models, such as grid search or random search, to reduce overfitting. You can use cross-validation (e.g., k-fold or stratified k-fold) to ensure that the search is robust.
-Ensemble methods: Try using bagging or boosting techniques, which can help reduce overfitting by combining predictions from multiple base classifiers. In your case, you're already using ensemble models (XGBoost, RandomForest, and LightGBM). However, you can still try to create an ensemble of these models to see if it further improves performance.
-Feature selection: Identify and remove irrelevant or highly correlated features that might be causing your model to overfit. Techniques like Recursive Feature Elimination, LASSO regression, or correlation analysis can help you select the most important features.
-Early stopping: Implement early stopping in your training process to prevent the models from overfitting. This can be done using the built-in early stopping functionality in XGBoost and LightGBM. You'll need to set a validation dataset and specify a metric for evaluation (e.g., 'auc' or 'f1').
-Regularization: Regularization techniques like L1 or L2 regularization can help prevent overfitting by adding a penalty to the loss function. Both XGBoost and LightGBM support regularization parameters that can be adjusted during training.
-Adjust the decision threshold: Instead of using the default 0.5 threshold for classifying instances, you can experiment with different decision thresholds to improve the balance between precision and recall.
-Cost-sensitive learning: Assign different misclassification costs to the positive and negative classes during training. This can help your model learn to better predict the minority class. Most tree-based algorithms like XGBoost, RandomForest, and LightGBM support this approach.
-Try other resampling techniques: Experiment with different resampling techniques like SMOTE, ADASYN, or random oversampling of the minority class, and random undersampling of the majority class to balance the dataset. Be sure to perform these operations on the training set only and not the validation/test set.
Keep in mind that it may be difficult to achieve perfect performance on an imbalanced dataset, but the goal is to minimize the generalization error as much as possible. It's essential to monitor your model's performance on a separate validation set during training and select the model with the best performance on the validation set to avoid overfitting.