The target classes are substantially imbalanced.
Class Imbalance Handling AI Prompt
This prompt tackles classification problems where the minority class matters more than raw accuracy. It compares common resampling and weighting approaches under a consistent evaluation setup. The goal is to choose the strategy that aligns best with both data imbalance and business costs.
Handle class imbalance in this classification dataset where {{minority_class}} is the minority class.
1. First, quantify the imbalance: ratio of majority to minority class
2. Explain why accuracy is a misleading metric for this problem
3. Implement and compare four strategies:
a. Class weight adjustment (class_weight='balanced' in sklearn)
b. Random oversampling of the minority class (RandomOverSampler)
c. SMOTE — Synthetic Minority Oversampling Technique
d. Undersampling the majority class (RandomUnderSampler)
4. For each strategy, train a LightGBM model and evaluate using: AUC-ROC, Precision, Recall, F1, and the confusion matrix
5. Recommend the best strategy for this specific imbalance ratio and business context
Note: apply all resampling only to the training set, never to validation or test sets.When to use this prompt
Accuracy alone would hide poor minority-class detection.
You want to compare weighting, oversampling, SMOTE, and undersampling side by side.
You need a recommendation grounded in metrics and practical trade-offs.
What the AI should return
An imbalance diagnosis, side-by-side evaluation of each handling strategy, confusion matrices and key classification metrics, and a recommendation for the best approach for the given problem context.
How to use this prompt
Open your data context
Load your dataset, notebook, or working environment so the AI can operate on the actual project context.
Copy the prompt text
Use the copy button above and paste the prompt into the AI assistant or prompt input area.
Review the output critically
Check whether the result matches your data, assumptions, and desired format before moving on.
Chain into the next prompt
Once you have the first result, continue deeper with related prompts in Model Building.
Frequently asked questions
What does the Class Imbalance Handling prompt do?+
It gives you a structured model building starting point for data scientist work and helps you move faster without starting from a blank page.
Who is this prompt for?+
It is designed for data scientist workflows and marked as intermediate, so it works well as a guided starting point for that level of experience.
What type of prompt is this?+
Class Imbalance Handling is a single prompt. You can copy it as-is, adapt it, or use it as one step inside a larger workflow.
Can I use this outside MLJAR Studio?+
Yes. The prompt text works in other AI tools too, but MLJAR Studio is the best fit when you want local execution, visible Python code, and reusable notebooks.
What should I open next?+
Natural next steps from here are AutoML Benchmark, Baseline Model, Custom Loss Function.