开始使用免费开始使用

处理非平稳性

在本练习中,您将再次可视化模型分数的波动,不过这次的数据统计特性会随时间变化。

model 中存有一个线性回归模型对象实例,交叉验证对象在 cv 中,数据在 Xy 中。

本练习是课程的一部分

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
编辑并运行代码