What is the purpose of cross-validation in model building?
Instruction: Explain the concept of cross-validation and its role in developing predictive models.
Updated
Official answer
Cross-validation estimates predictive performance by repeatedly fitting a model on one subset and scoring it on held-out observations. In ordinary k-fold validation, each fold is held out once and the other folds are used for training.
The split must represent the intended use. Keep observations from the same person or organization together when leakage would otherwise occur. For forecasting, train on earlier observations and validate on later ones; ordinary random folds can expose future information.
Fit every learned preprocessing step, feature selection rule and model using only the current training portion. Tune hyperparameters using an inner validation process; use an untouched test set or outer cross-validation to evaluate the resulting selection procedure.
Cross-validation can reveal and help choose controls for overfitting, but it does not prevent it automatically. Repeatedly choosing the best score on the same folds can overfit the selection process. Report the metric, splitting rule and variation across folds, while recognizing that fold scores share training data and are not independent replications.