Implement cross-validation correctly
Avoid data leakage in evaluation
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Write Python code to implement proper cross-validation for [classification/regression/time series] problem. For time series, use TimeSeriesSplit with purge gap. For classification, use StratifiedKFold. Include preprocessing inside the fold to avoid data leakage, and report mean ± std for each metric.
Personalize this prompt with Léa
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Use Cases
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Pour éviter les fuites entre groupes corrélés (ex. même patient), remplacez `StratifiedKFold` par `StratifiedGroupKFold`. Si vous utilisez `cross_validate`, fixez `random_state` et `shuffle=True` pour la reproductibilité. En séries temporelles, augmentez le `gap` de `TimeSeriesSplit` pour tenir compte de l’autocorrélation résiduelle.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.