Explore Library
Code QuizIntermediate

Three-Way Split Proportions

A common mistake when carving a 60/20/20 train/validation/test split with two calls.

Codepython
from sklearn.model_selection import train_test_split

# Goal: 60% train, 20% validation, 20% test
X_train, X_temp, y_train, y_temp = train_test_split(
    X, y, test_size=0.4, random_state=42)

X_val, X_test, y_val, y_test = train_test_split(
    X_temp, y_temp, test_size=0.2, random_state=42)

Why does this fail to produce the intended 60/20/20 split?