CertSafari
    Databricks Certified Machine Learning Associate· Lessons

    Domain 3 · Lesson 35/48

    Cross-validation vs a train-validation split

    Describe the benefits and downsides of using cross-validation over a train-validation split.

    14 min read
    2.07% of exam
    5 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Explain why one train-validation split gives a validation score that depends on which rows ended up in the validation set
    • Describe how k-fold cross-validation uses every row for both training and evaluation, and why that matters on small datasets
    • Estimate the extra compute cross-validation costs and say when a single split is the better choice
    • Recognise what cross-validation does not do: it does not replace the test set, create new rows, or suit time-ordered data when folds are random

    Key concept

    k-fold cross-validation — The training data is cut into k folds. Each fold is held out once while a model trains on the other k−1 folds, and the reported metric is the average of the k held-out scores. You get a steadier, more data-efficient estimate than one split gives, and you pay for it with k fits per candidate model.

    1.Why a single train-validation split gives a noisy score

    A train-validation split holds back part of the data, fits the model on the rest and scores it on the rows held back. The resulting number is meant to predict how the model will do on data it has never seen. Databricks AutoML uses this design by default: when you do not choose a split strategy, the dataset is randomly divided into train, validate and test portions.

    The weakness is that you get one number from one random partition. Suppose a churn dataset has 800 labelled rows and you split it 80/20. The validation set has 160 rows, so each misclassified row moves accuracy by about 0.6 percentage points. If one seed happens to put several hard-to-predict customers in validation and another seed doesn't, accuracy can swing from 0.71 to 0.83 with no change to the model. The model hasn't changed between those runs, only the luck of the draw, and the split cannot tell you which number is closer to the truth.

    Two other fixes look reasonable and also fail. Growing the validation share from 20% to 40% steadies the validation score a little, but it takes those rows away from training, which is the opposite of what a small dataset needs. Rerunning several times and reporting the best score is worse: it is selection bias, and it pushes the reported number toward the lucky end of the range. To actually reduce the noise, the estimate has to come from more than one partition.

    A single split also leaves data unused for training. Data that sits in a validation set never trains the model. When the data is also split into a test set, the training share gets smaller again, which hurts most when there were few rows to start with.

    Checkpoint 1 of 8· Check yourself

    Validation accuracy for an 800-row churn model, scored on an 80/20 split, swings between 0.71 and 0.83 depending on the split. Which change actually reduces the noise in the estimate without costing the model training data?

    Sources12

    2.How k-fold cross-validation averages away the noise

    k-fold cross-validation repeats the split k times in a structured way. The training data is cut into k folds of roughly equal size. In each round, one fold is held out for scoring and a fresh model is trained on the other k−1 folds. After k rounds, every row has been scored exactly once and has been used for training k−1 times. The reported metric is the mean of the k fold scores, and their spread shows how much the estimate moves from partition to partition.

    Five-fold cross-validation returns one score per held-out fold rather than a single numberpython
    >>> from sklearn.model_selection import cross_val_score
    >>> clf = svm.SVC(kernel='linear', C=1, random_state=42)
    >>> scores = cross_val_score(clf, X, y, cv=5)
    >>> scores
    array([0.96, 1. , 0.96, 0.96, 1. ])

    Each fold score is just as noisy as a single split. Averaging five of them gives a more trustworthy figure for the 800-row churn model than any one seed's 0.71 or 0.83. The data efficiency matters even more on a 400-row dataset. A fixed validation set would keep 80 rows out of training for good. With five-fold cross-validation, every row helps train four of the five models and is scored by the fifth. Cross-validation does not create synthetic rows or increase the sample size. It reuses the rows you already have in both roles.

    The same idea is used in Databricks tuning examples. Instead of scoring each candidate hyperparameter value on one holdout, the objective function below returns the mean cross-validated accuracy, so candidates are ranked on an average and not on one lucky partition. This example uses Hyperopt, which has since been deprecated on Databricks, but the cross-validation pattern is the same whichever tuning library calls it. Running cross-validation inside a fitting or tuning workflow is covered in cross-validation as part of model fitting.

    A tuning objective that scores each candidate by mean cross-validated accuracypython
    def objective(C):
        # Create a support vector classifier model
        clf = SVC(C=C)
    
        # Use the cross-validation accuracy to compare the models' performance
        accuracy = cross_val_score(clf, X, y).mean()
    
        # Hyperopt tries to minimize the objective function. A higher accuracy value means a better model, so you must return the negative accuracy.
        return {'loss': -accuracy, 'status': STATUS_OK}

    Checkpoint 2 of 8· Fill the gap

    This tuning objective gives Hyperopt one number for each candidate C. Which array method should complete it so that candidates are ranked fairly across the folds?

    def objective(C):
        # Create a support vector classifier model
        clf = SVC(C=C)
    
        # Use the cross-validation accuracy to compare the models' performance
        accuracy = cross_val_score(clf, X, y). ? ()
    
        # Hyperopt tries to minimize the objective function. A higher accuracy value means a better model, so you must return the negative accuracy.
        return {'loss': -accuracy, 'status': STATUS_OK}

    Checkpoint 3 of 8· Check yourself

    A team with 400 labelled rows replaces its train/validate/test split with five-fold cross-validation to tune a model. What should happen to the test set?

    Checkpoint 4 of 8· Exam question

    A data scientist has 800 labeled rows for a churn model, and a single 80/20 train-validation split produces a validation accuracy that swings between 0.71 and 0.83 depending on the random seed used for the split. The team wants a more trustworthy estimate of how the model will generalize before presenting results to stakeholders. Which change addresses this instability?

    Checkpoint 5 of 8· Exam question

    A team is training a gradient-boosted tree model on a dataset with only 400 rows, which is too small to comfortably carve out a separate validation set without starving the training set. Which property of k-fold cross-validation makes it a better fit than a single train-validation split for this specific situation?

    Sources342

    3.The cost: k fits for every candidate

    Every fold trains a separate model, so cross-validation multiplies training work by about k. One train-validation split fits each candidate once. Ten-fold cross-validation fits it ten times. In a hyperparameter search the multiplier applies to every candidate, so a search that fits 20 candidates on one split fits 200 models with ten folds. Spark ML has the same pair of choices: TrainValidationSplit scores each candidate on one holdout and CrossValidator scores it across folds. How to count every model in a grid search with cross-validation, including the final refit, is covered in counting models in grid search and cross-validation.

    Parallel execution reduces wall-clock time, not total compute. Fold fits are independent of each other, so they can run at the same time. Spark's CrossValidator has a parallelism setting for this, and Databricks tuning tools have a similar setting for running trials concurrently. Thirty hours of fitting is still thirty hours of cluster time, even if it finishes sooner. Running folds in parallel is covered in parallelizing single-node models for tuning.

    At large scale, the multiplier usually doesn't pay for itself. Cross-validation is not less accurate on 50 million rows. It is less necessary. A 20% holdout of 50 million rows has 10 million validation rows, so its score barely moves from seed to seed, and giving up those rows from training costs almost nothing. The benefits of cross-validation, a lower-variance estimate and full use of scarce data, are largest on small datasets and become negligible on large ones, while the cost keeps growing.

    Cross-validation also involves more setup. Any preprocessing that learns from data, such as scaling, imputation or encoding, has to be refit inside each fold on that fold's training rows. Otherwise statistics from the held-out fold leak into training and inflate every fold score. Putting the preprocessing and the model in one pipeline handles this. See building a training pipeline.

    Checkpoint 6 of 8· Check yourself

    A team tunes 15 gradient-boosted candidates on 30 million rows, and one fit takes about two hours. Why is a single 80/20 train-validation split the better choice than five-fold cross-validation here?

    Checkpoint 7 of 8· Exam question

    A data scientist is deciding between a single train-validation split and 10-fold cross-validation for tuning a random forest on a dataset with 50 million rows, where a single training run already takes several hours on the cluster. Which downside of cross-validation is most relevant to this decision?

    Sources32

    4.Choosing between cross-validation and a single split

    Choose based on two things: how much data you have and how expensive one fit is. When rows are scarce and each fit is quick, cross-validation gives a much more reliable estimate for little extra cost. When data is plentiful and each fit takes hours, a single split gives an estimate that is already stable, at a fraction of the cost.

    Single train-validation split compared with k-fold cross-validation
    AspectSingle split (train_test_split, TrainValidationSplit)k-fold (cross_val_score, CrossValidator)
    Fits per candidate1k
    How the estimate is formedOne score from one random partitionMean (and spread) of k held-out fold scores
    Rows used for trainingOnly the training share; validation rows never trainEvery row trains in k−1 folds and is scored in one
    Sensitivity to the split seedHigh on small dataMuch lower; noise averages out across folds
    Best fitLarge datasets, expensive models, quick iterationSmall or moderate datasets, final model comparisons
    Separate test set still neededYesYes

    Checkpoint 8 of 8· Match them up

    Match each evaluation approach to the project it suits best, given how much data there is, how long one fit takes and how the rows are ordered.

    Tap a term, then the definition that fits it.

    Sources5

    Sources

    (5)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “the dataset is randomly split into 60% train split, 20% validate split, and 20% test split.”
      ↩︎ Why a single train-validation split gives a noisy score
    2. 2.
      “by partitioning the available data into three sets, we drastically reduce the number of samples which can be used for learning the model”
      ↩︎ Why a single train-validation split gives a noisy score
      “A test set should still be held out for final evaluation, but the validation set is no longer needed when doing CV.”
      ↩︎ How k-fold cross-validation averages away the noise
      “because the parameters can be tweaked until the estimator performs optimally.”
      ↩︎ How k-fold cross-validation averages away the noise
      “This approach can be computationally expensive, but does not waste too much data (as is the case when fixing an arbitrary validation set)”
      ↩︎ The cost: k fits for every candidate
      “The performance measure reported by k-fold cross-validation is then the average of the values computed in the loop.”
      ↩︎ Key concept
      “the results can depend on a particular random choice for the pair of (train, validation) sets.”
      ↩︎ Exam trap 1
      “A test set should still be held out for final evaluation, but the validation set is no longer needed when doing CV.”
      ↩︎ Exam trap 2
      “This approach can be computationally expensive, but does not waste too much data (as is the case when fixing an arbitrary validation set)”
      ↩︎ Exam trap 3
      “the results can depend on a particular random choice for the pair of (train, validation) sets.”
      ↩︎ Prediction
      “This approach can be computationally expensive, but does not waste too much data”
      ↩︎ Checkpoint
    3. 3.
      “Use the cross-validation accuracy to compare the models' performance”
      ↩︎ How k-fold cross-validation averages away the noise
      “parallelism: Number of models to fit and evaluate concurrently.”
      ↩︎ The cost: k fits for every candidate
    4. 5.
      “For forecasting tasks, AutoML uses time series cross-validation.”
      ↩︎ Choosing between cross-validation and a single split
      “This method incrementally extends the training dataset chronologically and performs validation on subsequent time points.”
      ↩︎ Choosing between cross-validation and a single split

    Ready to test yourself?

    Practise Databricks Certified Machine Learning Associate in quiz mode.

    Spotted a mistake, or was something unclear? Tell us.