JSP's Deep learning

[Data Preprocessing] train_test_split의 stratify 옵션을 데이터 균형 분할 본문

Data Processing/Data Preprocessing

[Data Preprocessing] train_test_split의 stratify 옵션을 데이터 균형 분할

_JSP_ 2022. 6. 2. 13:50

1. 코드

X_train, X_test, y_train, y_test = train_test_split(X_data, y_data, test_size=0.2, random_state=0, stratify=y_data)
  • 또한 Train dataset과 Test dataset을 분할할 때, 라벨의 비율에 맞게 분할할 필요가 있다.
  • 다음의 코드를 통해서 y_data의 label 분포에 맞게 데이터를 분할한다.
Comments