Measuring how well a model does with a single split leaves you at the mercy of luck. Cross-validation splits the data into k pieces, uses each piece in turn as the test and the rest for training, scores k times, and averages. It gives a more trustworthy, less lopsided score. Complete cross_val_mean(model, X, y, k). model a scikit-learn model to train and predict with. X, y features and labels. k the number of pieces to split into. Use scikit-learn's cross-validation to score accuracy k times and return the mean. Example With k=5 you get a single number: the average of five accuracies.
This challenge asks you to complete a function that uses scikit-learn's cross-validation to score a classifier's accuracy k times and return the mean. It takes a model, features, labels, and the number of pieces k, uses classification accuracy as the score, and returns a single averaged number. It practices the fundamentals of getting a more trustworthy evaluation score that doesn't hinge on a single split.
Cross-validation splits the data into several pieces, uses each piece in turn for testing while training on the rest, scores several times, and averages. Relying on a single split leaves the score at the mercy of luck, but averaging over several runs gives a steadier evaluation. This problem uses scikit-learn's cross-validation to produce that average and verifies the result by checking the numbers.