비정상성 대응하기
이 연습 문제에서는 모델 점수의 변동을 다시 시각화하되, 이번에는 시간이 지나면서 통계적 특성이 변하는 데이터에 대해 살펴보겠습니다.
model에는 Linear regression 모델 객체가, cv에는 교차 검증 객체가, X와 y에는 데이터가 저장되어 있어요.
이 연습은 강의의 일부입니다
Python으로 배우는 시계열 데이터 Machine Learning
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Pre-initialize window sizes
window_sizes = [25, 50, 75, 100]
# Create an empty DataFrame to collect the stores
all_scores = ____(index=times_scores)
# Generate scores for each split to see how the model performs over time
for window in window_sizes:
# Create cross-validation object using a limited lookback window
cv = ____(n_splits=100, max_train_size=window)
# Calculate scores across all CV splits and collect them in a DataFrame
this_scores = ____(____, ____, ____, cv=cv, scoring=my_pearsonr)
all_scores['Length {}'.format(window)] = this_scores