NeuralProphet 0.2 : ノートブック : スパースな自己回帰 (翻訳/解説)
翻訳 : (株)クラスキャット セールスインフォメーション
作成日時 : 07/23/2021 (Beta 0.2.7)
* 本ページは、NeuralProphet の以下のドキュメントを翻訳した上で適宜、補足説明したものです:
* サンプルコードの動作確認はしておりますが、必要な場合には適宜、追加改変しています。
* ご自由にリンクを張って頂いてかまいませんが、sales-info@classcat.com までご一報いただけると嬉しいです。
- 人工知能研究開発支援
- 人工知能研修サービス(経営者層向けオンサイト研修)
- テクニカルコンサルティングサービス
- 実証実験(プロトタイプ構築)
- アプリケーションへの実装
- 人工知能研修サービス
- PoC(概念実証)を失敗させないための支援
- テレワーク & オンライン授業を支援
- お住まいの地域に関係なく Web ブラウザからご参加頂けます。事前登録 が必要ですのでご注意ください。
- ウェビナー運用には弊社製品「ClassCat® Webinar」を利用しています。
◆ お問合せ : 本件に関するお問い合わせ先は下記までお願いいたします。
株式会社クラスキャット セールス・マーケティング本部 セールス・インフォメーション |
E-Mail:sales-info@classcat.com ; WebSite: https://www.classcat.com/ ; Facebook |
NeuralProphet 0.2 : ノートブック : スパースな自己回帰
ここでは NeuralProphet を 5 分解像度のデータに適合させます (Yosemite の毎日の気温)。これはスパース性にフォーカスした、example ノートブック autoregression_yosemite_temps の続きです。
if 'google.colab' in str(get_ipython()):
!pip install git+https://github.com/ourownstory/neural_prophet.git # may take a while
#!pip install neuralprophet # much faster, but may not have the latest upgrades/bugfixes
data_location = "https://raw.githubusercontent.com/ourownstory/neural_prophet/master/"
else:
data_location = "../"
import pandas as pd
from neuralprophet import NeuralProphet, set_log_level
set_log_level("ERROR")
df = pd.read_csv(data_location + "example_data/yosemite_temps.csv")
# df.head(3)
AR 係数をスパース化する
NeuralProphet の自己回帰コンポーネントは AR-Net として定義されます (論文, github)。そして、AR 係数にスパース性を誘導したいのであれば ar_sparsity をより小さい数値に設定できます。
けれども、複数のコンポーネントと正則化でモデルを適合させるのは困難である可能性があり、訓練ハイパーパラメータを手動制御する必要があるかもしれません。
スパース性を 50% に設定することで開始します。
m = NeuralProphet(
n_lags=6*12,
n_forecasts=3*12,
changepoints_range=0.95,
n_changepoints=30,
weekly_seasonality=False,
# batch_size=64,
# epochs=100,
# learning_rate=0.1,
ar_sparsity=0.5,
)
metrics = m.fit(df, freq='5min') # validate_each_epoch=True, plot_live_loss=True
fig_param = m.plot_parameters()
m = m.highlight_nth_step_ahead_of_each_forecast(1)
fig_param = m.plot_parameters()
m = m.highlight_nth_step_ahead_of_each_forecast(36)
fig_param = m.plot_parameters()
非ゼロ AR-係数を更に削減する
ar_sparsity を低く設定することで、非ゼロ重みの数を更に削減できます。ここではそれを 10 % に設定します :
m = NeuralProphet(
n_lags=6*12,
n_forecasts=3*12,
changepoints_range=0.95,
n_changepoints=30,
weekly_seasonality=False,
# batch_size=64,
# epochs=100,
# learning_rate=0.1,
ar_sparsity=0.1,
)
metrics = m.fit(df, freq='5min')
fig_param = m.plot_parameters()
m = m.highlight_nth_step_ahead_of_each_forecast(1)
fig_param = m.plot_parameters()
m = m.highlight_nth_step_ahead_of_each_forecast(36)
fig_param = m.plot_parameters()
極端なスパース性
より低く ar_sparsity を設定すれば、より少ない非ゼロ重みがモデルにより適合されます。ここではそれを 1 % に設定します、これは単一の非ゼロのラグに繋がるはずです。
Note : 極端な値は訓練の不安定性に繋がる可能性があります。
m = NeuralProphet(
n_lags=6*12,
n_forecasts=3*12,
changepoints_range=0.95,
n_changepoints=30,
weekly_seasonality=False,
# batch_size=64,
# epochs=100,
# learning_rate=0.1,
ar_sparsity=0.01,
)
metrics = m.fit(df, freq='5min')
fig_param = m.plot_parameters()
m = m.highlight_nth_step_ahead_of_each_forecast(1)
fig_param = m.plot_parameters()
m = m.highlight_nth_step_ahead_of_each_forecast(36)
fig_param = m.plot_parameters()
以上