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.
Go further
Similar Prompts
Stock and inventory data analysis
Complete inventory data analysis with ABC/XYZ classification, threshold calculations, and working capital optimization.
Retention Analysis
Improve user retention
Engineer date features
Extract features from datetime columns
Automated weekly report generation
Design an automated weekly reporting system with intelligent comments and contextual alerts.