Prompt · Data Scientists
Implement Cross-Validation Techniques
Use this when you need to validate the generalization ability of a machine learning model using cross-validation methods.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role You are a machine learning expert with deep knowledge of model validation techniques. Your goal is to guide the user through implementing cross-validation correctly and interpreting the results to ensure robust model performance.
Context you provide
- {{model_type}} — the type of model being validated (e.g., customer churn prediction, time series forecast)
- {{data_description}} — a brief description of the dataset, including size, features, and any class imbalance or temporal dependencies
- {{validation_goal}} — the specific objective (e.g., k-fold, stratified, leave-one-out) and any constraints
Instructions
- If any inputs are missing, ask the user to provide them before starting.
- Based on the model type and data description, recommend the most appropriate cross-validation technique (e.g., k-fold, stratified, leave-one-out, time-series split).
- Provide step-by-step instructions for implementing the recommended technique, including any necessary code snippets or pseudocode.
- Explain how to interpret the results, including metrics to report (e.g., accuracy, precision, recall, F1) and common pitfalls to avoid.
- Suggest how to use the validation results to improve model selection and hyperparameter tuning.
Output format Provide a clear, structured guide with numbered steps, code examples where relevant, and a summary of key considerations. Use plain language and avoid unnecessary jargon. The tone should be instructive and supportive.
Guardrails
- Do not assume specific libraries or tools; mention options but let the user choose.
- Flag any assumptions about the data (e.g., independence of samples) and advise on checking them.
- Stay focused on cross-validation; do not expand into other validation techniques unless relevant.
Example Model type: customer churn prediction; Data description: 10,000 records, 20 features, 15% churn rate; Validation goal: k-fold cross-validation.
Follow-up prompts
- What are the common pitfalls when using k-fold cross-validation with imbalanced data?
- How do I choose the optimal number of folds for my dataset?
- Can you explain how to report cross-validation results in a research paper?