始める無料で始める

非定常性への対処

この演習では、モデルのスコアのばらつきを再び可視化しますが、今回は時間とともに統計量が変化するデータを対象にします。

線形回帰モデルのインスタンスはmodelに、クロスバリデーション用のオブジェクトはcvに、データはXyに格納されています。

この演習はコースの一部です

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
コードを編集して実行