การรับมือกับ Non-stationarity
ในแบบฝึกหัดนี้ จะได้ลองแสดงภาพความผันแปรของคะแนนโมเดลอีกครั้ง แต่คราวนี้เป็นข้อมูลที่สถิติเปลี่ยนแปลงไปตามเวลา
โมเดล Linear regression ถูกเก็บไว้ในตัวแปร model, อ็อบเจกต์ cross-validation ใน cv และข้อมูลใน X และ y
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Machine Learning สำหรับข้อมูล Time Series ใน Python
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# 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