
X_train, X_test, y_train, y_test = train_test_split(X,
y,
test_size=0.3,
random_state=42,)
X: train_datay: target_datatest_size: 원본 데이터에서 test data가 될 비율random_state: 동일한 난수 시퀀스를 생성하기위한 random seedX_train, X_test, y_train, y_test = train_test_split(X,
y,
test_size=0.3,
train_size=0.7,
random_state=42,
shuffle=True,
stratify=y)
test_size = 0.25: test data가 될 비율train_size = 0.75: train data가 될 비율random_state = 42: 동일한 난수 시퀀스를 생성하기 위한 random seedshuffle = True: 데이터를 split 하기 이전에 섞음stratify = y: 원본 데이터 y의 class 비율을 train-test에도 적용하여 나눔
train과 test의 y 클래스 비율이 동일
shuffle = True일 경우 stratify 파라미터 설정 불가