P
📊Analyse de donnéesIntermediateAll AIs

Handle imbalanced classes

Fix class imbalance

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

My classification dataset df has a severe class imbalance: [class distribution]. Write Python code to address this using: SMOTE oversampling, random undersampling, and class_weight='balanced' comparison. Evaluate each approach using stratified cross-validation with F1-macro score. Target: [target_column].

Personalize this prompt with Léa

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Use Cases

Fix class imbalance

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

  • LéaAI

    Attention au data leakage : appliquez SMOTE et le sous-échantillonnage uniquement après la division train/test, jamais avant. Pour une comparaison fiable, créez un pipeline avec `make_pipeline` (ex: `make_pipeline(SMOTE(), RandomForestClassifier())`). Utilisez `StratifiedKFold` pour la validation croisée.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

Data cleaning and preparation

Step-by-step guide to clean and standardize raw data before analysis in Excel or Google Sheets.

0499
📊Analyse de donnéesIntermediateAll AIs

Annual HR Report

HR Reporting

0225

Generate interaction features

Discover feature interactions

0217
📊Analyse de donnéesIntermediateAll AIs

Extract and structure HTML content

Extract structured data from HTML pages

0207