Skip to main content

How do you perform cross-validation?

Mid Python
Quick Answer Cross-validation evaluates model performance more reliably than single train/test split. KFold: split data into K folds, train on K-1, test on 1, repeat K times, average scores. StratifiedKFold for classification (preserves class distribution in each fold). cross_val_score(model, X, y, cv=5) does 5-fold CV. Use for: hyperparameter tuning (GridSearchCV uses CV internally), comparing models, reporting performance.

Answer

Split data into multiple folds.
Train and test repeatedly.
Ensures robust model evaluation.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice