← Каталог
Алгоритмы ИИ — Практические аспекты разделения
Фрагмент из «Алгоритмы ИИ»: Практические аспекты разделения.
from sklearn.model_selection import train_test_split
X_train, X_temp, y_train, y_temp = train_test_split(
X, y,
test_size=0.4,
random_state=42,
stratify=y
)
X_val, X_test, y_val, y_test = train_test_split(
X_temp, y_temp,
test_size=0.5,
random_state=42,
stratify=y_temp
) from sklearn.model_selection import train_test_split
X_train, X_temp, y_train, y_temp = train_test_split(
X, y,
test_size=0.4,
random_state=42,
stratify=y
)
X_val, X_test, y_val, y_test = train_test_split(
X_temp, y_temp,
test_size=0.5,
random_state=42,
stratify=y_temp
)