KFold 교차 검증
ML 모델을 다룰 때는 보지 못한 데이터에서 성능을 평가하는 것이 중요합니다. 이를 위한 일반적인 기법이 k-fold 교차 검증이에요. 이 연습 문제에서는 k-fold 교차 검증이 데이터셋을 학습용과 테스트용으로 어떻게 분할하는지 살펴보겠습니다. KFold와 심장 질환 데이터셋의 특성 heart_disease_df_X는 이미 불러와 드렸어요.
이 연습은 강의의 일부입니다
엔드 투 엔드 Machine Learning
연습 안내
n_splits=5,shuffle=True,random_state=42로 KFold 객체를 생성하세요.kfold.split()을 사용해 데이터를 분할하세요.- 학습 분할과 테스트 분할 각각의 데이터 포인트 개수를 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create a KFold object
kfold = ____(____, ____, ____)
# Get the train and test data from the first split from the shuffled KFold
train_data_split, test_data_split = next(____.____(____))
# Print out the number of datapoints in the train and test splits
print("Number of training datapoints in heart_disease_df_X:", ____)
print("Number of training datapoints in split:", ____)
print("Number of testing datapoints in split:", ____)