AIによる翻訳。英語版は人による検証済みである。 原文を読む

時系列予測

教材キット

2026.11.23版(書籍の現行版)より。書籍が更新されると変わる。出典を明記すれば、自由に利用および改変できる。

シラバス

読書時間は章の本文に基づく。学習者はLabまたは自分のマシンでコード例も実行する。

週ごとに一章: 10 週

5 週間後

学習目標と概要

各章の学習目標はその冒頭の一文である。各構成案は章の節に従い、定義される用語、例を実行する前に求められる予測、各節が締めくくる規則を含む。

1. 明日の需要を予測する

読了まで約42分。4 例。

本章では、明日の需要に対する最初の予測と、以降のあらゆる予測が上回らなければならない単純なベースラインを作る。

講義概要: 7 節
  1. 事例とそのデータ
    • 実践ルール 予測を行う前に、切り出しをデータカードと照合する。ファイルには 30 の顧客が含まれているはずであり、例ではそのうち何顧客が丸2年分の時間別の行を持つかを数える。これらの件数はカードと一致しなければならない。MT_223 が欠けており、その理由が説明されていることを確認する。カードと一致しない切り出しは別のデータであり、そこから計算されるすべての数値は、本書のデータではなくそのデータを記述している。
  2. Load one client's hourly demand
    • 実行 load-lead-client.py
    • 実践ルール Choose the client and the window first, then count the quirks in that window's history before any model sees it. If a history holds a clock-change label or a before_first_reading row, do not hand it to a model unchanged, because the model will read the label's value as demand. Chapter 3 and Chapter 4 give the rules for those rows. A window that holds neither can use its rows as they are, as this chapter does.
  3. 季節ナイーブ法で翌日を予測する
    • 実行 seasonal-naive-next-day.py
    • 実践ルール 日周期を持つ時間単位の系列を比較するときは、毎回、季節ナイーブ法を含めること。当てはめが不要なので、追加の費用なしにすべてのウィンドウで実行できる。同じウィンドウで季節ナイーブ法を上回れないモデルは、余分な手間に見合う価値を示していない。スコアを読む前に、予測に欠損値がないかを確認すること。最後の季節に測定値の欠損があれば、それが予測の欠損になるからである。それらの時間を、モデルの実行前に補完する規則は、第 3 章で示す。
  4. Forecast the next day with one model
    • 実行 autoets-next-day.py
    • 実践ルール Add a model only with a baseline it has to beat on the same windows. Refit the model at each cutoff, using history from before that cutoff only. A model fitted once on the whole series and then scored on that series has seen the answers, and its score is not a forecast score.
  5. 保留した1週間で両者を採点する
    • 実行 figure-held-out-week-forecasts.py
    • 実践ルール 各モデルは、採点対象の時間を履歴に含めずに作った予測で、1日より長い期間にわたって採点し、各スコアの根拠となるウィンドウ数と時間数を報告する。モデルの比較は、同じウィンドウの上でのみ行う。MAE と RMSE は合わせて読む。どちらのモデルが良いかについて両者が食い違う場合は、選ぶ前にウィンドウ内の最大の外れを調べる。少数の大きな外れが結果を左右しうるからである。
  6. 本番環境で何が問題になるか
    • 実践ルール スコアを信頼する前に、次の3点をこの順に確認する。各ウィンドウの最初の予測時間がそのカットオフであること、各履歴がカットオフより前で終わり、履歴の全長を保持していること、そして欠測した予測がないことである。最初の2点についてはヘルパーがエラーを送出し、3点目は例が出力する。スコアが知見になるのは、3点すべてを満たした後だけである。
  7. この章で行った決定

2. モデルが超えるべきベースラインを設定する

読了まで約46分。3 例。

本章では、ある顧客の翌日需要予測に対して、ナイーブ予測、季節ナイーブ予測、週平均予測という三つのベースラインを計算する。

講義概要: 7 節
  1. なぜ最初にベースラインを置くのか
    • 実践ルール すべてのベースラインは、比較対象となるモデルと同じウィンドウ、履歴、採点コードで採点すること。また、各ベースラインのスコアを読む前に、そのベースラインの欠けている予測の数を数えること。異なる時刻で採点されたベースラインに勝ったモデルは、そのベースラインに勝ったことにはならない。
  2. Three baselines to beat
    • 実行 naive-baselines-held-out-week.py
    • 実行 figure-baseline-window-errors.py
    • 実践ルール Start from naive and seasonal naive, both from the library, and add average of weeks when the series has a weekly rhythm worth testing. Check one forecast by hand against its formula before you rely on a baseline: pick one cutoff, compute one hour from the readings in its history, and compare the result with the forecast.
  3. Scale errors with MASE
    • 実行 mase-scale-leak-check.py
    • 実践ルール Report MASE beside MAE whenever the clients you compare differ in size, and say in the same sentence which history the scale comes from. Read MASE as a ratio of two mean errors, one from the scored hours and one from the history. It is not a percentage gain over seasonal naive, even when the MASE is well below 1.
  4. MASE のスケールは履歴から取る
    • 実践ルール スケールには最初のテスト日より前の測定値だけを渡し、時計の切り替えに当たる測定値をマスクし、使う最後の測定値を出力すること。この測定値が最初のテスト日の直前の時間であることを確認する。二つのスケールの差が小さくても、手順が正しいことの証明にはならない。行の検査がそれを示す。
  5. ベースラインのスコアを読む
    • 実践ルール 各ベースラインの MASE を 1 と、また他のベースラインと比べて読み、1 週間だけで勝者を決めてはならない。モデルが優れていると見なせるのは、複数の窓の集合で最良のベースラインを上回り、かつその差が印字されたスコアの丸めより大きいときに限る。
  6. 本番で何が問題になるか
    • 実践ルール ベースラインの入力とそのスケールの入力は、次の順で確認する。すべての手法で同じウィンドウを使うこと。スケールは過去の読み取り値だけを読み、その最後の読み取り値を出力すること。季節ラグのために1時間ごとの履歴が途切れていないこと。季節がデータの周期と一致していること。各確認は1行の出力か1つの件数で足り、確認に失敗した場合は、修正されるまで比較を止める。
  7. この章で行った決定

3. 未来を見ずにバックテストを行う

読了まで約56分。8 例。

この章では、予測の履歴に未来の情報を混入させずに、翌日予測を1年分のカットオフで採点する方法、データに含まれる2つの時刻切り替えの時間帯を扱う方法、カットオフより後を読み取る特徴量を検出するシフトテストの実行方法も扱う。

講義概要: 10 節
  1. 1週間のテストが誤解を招く理由
    • 実践ルール 2つの手法の差を信頼する前に、1年分のカットオフを用いることが望ましい。費用の都合でそれより少なくなる場合は、第4章から第9章のように、各スコアの横にその旨を明記する。標本が1年のうちの特異な日に届くようにする。各数値の背後にあるウィンドウ数と採点された時間数を報告する。1週間から得た数値は1つの標本であり、読者がそれを見て取れるようにしておくべきである。
  2. Roll the cutoff forward
    • 実行 backtest-sundays-2014.py
    • 実行 figure-rolling-windows.py
    • 実践ルール Set the history length explicitly, in hours, and check that it is the same for every window. When a library loops over windows for you, read how it sets the training slice before you trust its output, because its default may be an expanding window rather than the length you chose.
  3. Keep the future out of the history
    • 実行 history-cut-check.py
    • 実践ルール Slice each window's history by its cutoff, never by the start of its test window, and pass a library only the rows it may use. Check the first and last timestamps of every history, and make sure the last one is an hour before the cutoff.
  4. 時計の切り替えを知る
  5. The March hour that reads zero
    • 実行 clock-change-census.py
    • 実行 clock-gap-daily-cutoffs.py
    • 実践ルール Treat a 01:00 reading of zero on a March clock-change day as a missing hour, not as zero demand. Keep it out of a model's history and out of the scores, and do not let a seasonal method copy it into the next day.
  6. 2 回分のエネルギーを含む 10 月の 1 時間
    • 実行 clock-repeat-daily-cutoffs.py
    • 実践ルール 10 月の 01:00 のラベルは、通常の 1 時間として扱わず、1 つの枠に 2 時間分のエネルギーが入ったものとして扱う。1 時間分に見せるために半分にしてはならない。その理由は次の節で述べる。
  7. Mark clock-change hours as missing
    • 実行 clock-masked-backtest.py
    • 実践ルール Mark both clock-change hours missing in every history and every score, count the masked hours in your report, and fill them from the history before the cutoff only when the model cannot take missing values. If the count of masked hours changes from one run to the next, the sample or the file's flags have changed, and you should find out why before you rerun the scores.
  8. Check a backtest for leakage
    • 実行 leakage-shift-check.py
    • 実践ルール Keep every lag at least the horizon, 24 hours, so that the reading a lag uses for any target hour was known at the cutoff. Before you trust a backtest with features, run both halves of the shift test on every feature, at several cutoffs spread through the year, and require zero differing rows for every feature the model reads. A feature that differs is reading the future, so fix or remove it before you score anything.
  9. What goes wrong in production
    • 実践ルール Run the clock and shift checks again on every data refresh, and before any change to the sample's dates, the history length or the scale. Keep the masked-hour count, the census counts and the shift-test counts in the run log next to the scores, so that a later change in either can be traced to its cause.
  10. 本章で下した決定

4. 顧客ごとに統計モデルを当てはめる

読了まで約54分。9 例。

供給事業者の各顧客には、それぞれ翌日予測が必要である。

講義概要: 10 節
  1. Why a statistical model comes next
    • 実行 figure-lead-client-fortnight.py
    • 実践ルール Fit one model per client only after a baseline and a backtest are in place. Count the fits before you choose the number of windows: clients, times windows, times refits if you run the model every day. Use the same cutoffs and history for every model in a comparison. Otherwise the comparison measures the windows, not the models.
  2. Fit exponential smoothing
    • 実行 figure-smoothing-weights.py
    • 実行 autoets-subset-backtest.py
    • 実行 flat-form-check.py
    • 実行 autoets-forced-season-backtest.py
    • 実践ルール Start with AutoETS for hourly demand with season_length=24, and print the chosen forms in every backtest. When a client takes a flat form, check that its seasonal form is not failing. If the seasonal fit has the lower likelihood, force the season with model="ZZA", and score both forms on earlier windows before you keep either: cutoffs before the held-out week that the report does not score, such as the four ordinary days in late November and early December 2014, which Chapter 5 sets aside for choices. The standard cutoffs show the comparison here, but they do not decide it. When a forecast gets worse, look first for a form that changed between cutoffs.
  3. 固定の季節 ARIMA を当てはめる
    • 実行 figure-seasonal-difference.py
    • 実行 arima-summary-look.py
    • 実践ルール 探索が遅すぎてカットオフごとには実行できないときは、次数を固定し、呼び出しに書き込む。summary を一度表示し、挙げられた項が意図したものであることを確かめる。固定した次数は、ほかのモデルと同様にカットオフごとに再当てはめする。次数は固定のままであり、係数は固定ではない。
  4. 同じカットオフでモデルを比較する
    • 実行 arima-subset-backtest.py
    • 実践ルール すべての候補を、同じカットオフ、同じ履歴、同じスケールで採点し、MAE と MASE を並べて報告する。両者が食い違う場合は、意思決定がどちらを必要とするかを明示する。MASE の差がおよそ 0.1 に満たない 2 つのモデルから選ぶ前には、窓を増やすことを勧める。この閾値は、このサンプルからの判断であり、測定値ではない。
  5. 遅れて始まるクライアント
  6. ゼロから始まる履歴
  7. 各系列を最初の読み取り値から始める
    • 実践ルール クライアントの履歴にゼロが含まれるときは、最初の非ゼロの読み取り値が履歴の内側にあるかを確認する。内側にある場合は、ゼロの割合にかかわらず、モデルが履歴を見る前に開始ルールを適用する。先頭のゼロは使用量ではないからである。まず系列全体に対して check_start_rule を実行し、失敗した場合は、何かを除外する前にその理由を調べる。各カットオフで履歴の長さを出力する。履歴が短いことは、ルールが取りすぎたことを示す最初の兆候だからである。
  8. 本書が season 24 で自動 ARIMA を避ける理由
    • 実践ルール 毎日再学習するスケジュールで、1 時間ごとのデータに対して season 24 の自動探索を実行しないこと。採用する前に、1 クライアントで探索の所要時間を測ること。遅すぎる場合は次数を固定し、その次数をバックテストで検証すること。
  9. 本番運用で起こりがちな問題
  10. この章で行った決定

5. カレンダー特徴量とラグ特徴量を追加する

読了まで約55分。4 例。

この章を終えると、1 クライアントの毎時の履歴を特徴量テーブルに変換できるようになる。

講義概要: 8 節
  1. Turn history into features
    • 実践ルール Build every feature row as if the cutoff were the last reading you have. A feature for a forecast hour must be computable from readings at or before the cutoff of its window. Before any shift test, ask whether the feature is known at the cutoff. Then check it with the shift test from Chapter 3, and do not train on a table you have not checked.
  2. 予測から見えるラグを加える
    • 実践ルール ホライズン以上の長さのラグだけを使う。ホライズンが 24 時間であれば 24 時間以上を意味し、本書では 24 と 168 を用いる。それより短いラグには理由が必要であり、短いラグを使うモデルは、そのスコアを信頼する前にシフト検定に合格しなければならない。ラグにも時計の規則を適用し、ラグがマスクされた時刻を読む行の数と、履歴から補完した時刻の数を数える。
  3. Add calendar and holiday features
    • 実行 figure-holiday-like-sunday.py
    • 実践ルール Add the calendar features the case's rhythm needs, and keep each one only if it helps on the same windows, as the next section measures. For holidays, use a calendar that covers every year in your data and every year you will forecast, and print how many holidays it holds for those years. A count of zero for a forecast year means the list is missing that year, not that the year had no holidays.
  4. 決定用ウィンドウで選ぶ
    • 実践ルール 特徴量は、ホールドアウトした週より前にあり、かつその特徴量が対象とする種類の日を含むウィンドウで選ぶ。祝日の特徴量には祝日のウィンドウが必要である。標準のカットオフは、選択結果の横に報告するが、選択を行うためには決して用いない。
  5. 各特徴量が加えるものを測る
    • 実行 lgbm-feature-sets.py
    • 実践ルール 特徴量セットは、同じウィンドウ上で、それが拡張するセットに対してクライアントごとの平均 MASE を下げる場合にだけ残す。プールした MAE をその隣に報告する。2 つの見方の不一致を解消するためにモデルを調整してはならない。
  6. Catch a lag that leaks the future
    • 実行 lag-leak-check.py
    • 実行 figure-leaky-lag-forecast.py
    • 実践ルール Run the shift test on every lag and every window feature before a model trains on it, and treat any differing row as a leak until you have shown otherwise. When an error falls sharply after you add a feature, check that feature first, before you credit it.
  7. 本番で起きる問題
    • 実践ルール データやライブラリが変わるたびに、予測対象の各年の祝日件数、マスクされた時間帯とそれが及ぶ行、およびラグの長さを再確認する。すべてのラグにシフトテストを実行し、プールした MAE の横で顧客ごとの MASE を読む。確認の結果が変わった場合は、次の予測を公開する前に、いったん止めて原因を読む。
  8. Decisions this chapter made

6. 1つのモデルで多数のクライアントを予測する

読了まで約52分。5 例。

この章を終えるとき、読者の手元には、30クライアント全体を対象とする1つのグローバルモデルと、後から開始したクライアントの先頭のゼロをそのモデルに入れないための開始ルールと、同じカットオフで各クライアントについてそのモデルを季節ナイーブ予測と比べるスコアがある。

講義概要: 7 節
  1. One model for many clients
    • 実践ルール Fit one global model when your series share a shape and you must forecast many of them on each window. Scale each series' target with statistics from that window's history only, use only lags at least as long as the horizon, and fit once per window, not once per series. Then score the model per series against a baseline on the same windows, as the sections below do, before you trust its pooled error.
  2. 各クライアントを識別する
    • 実行 client-identifier-check.py
    • 実践ルール クライアント識別子は、第5章の基準のもとで、もう一つの特徴量として扱う。判断用ウィンドウでクライアントごとの平均MASEが下がる場合に限って残し、プールしたMAEを併せて示す。判断が僅差なら、そのことを明記し、別のウィンドウで測り直す。識別子が優位なら、その代償を書き留める。新しいクライアントは履歴ができるまで学習済みの分岐を持たず、そのクライアントを予測するにはモデルを再学習しなければならない。
  3. Apply the start rule to every client
    • 実行 start-rule-leak-check.py
    • 実行 global-model-raw-starts.py
    • 実践ルール Apply the start rule to every series that has leading zeros, and find each first reading from the rows before the cutoff. When the rule refuses a cutoff, stop the run and name the client and the cutoff. Do not fill the zeros, and do not publish a panel with a client missing. Judge the rule by the scale and by the windows where zeros enter the history, and expect the MAE effect to be small and mixed.
  4. Score thirty clients on the same cutoffs
    • 実行 global-model-thirty-clients.py
    • 実行 figure-client-mase-global-vs-naive.py
    • 実践ルール Score a global model per client on the same cutoffs as the baseline, with the MASE scale fixed before the first scored cutoff. Report the mean per-client MASE beside seasonal naive, and print the counts of clients and scored hours so a reader can check them. State any client left out of MASE and why. Read the pooled MAE and RMSE as the cost in kilowatt hours, not as the measure of model quality.
  5. 実行時間の見積もり
    • 実践ルール バックテストを実行する前に、適合の回数を数える。クライアントごとの手法ではクライアント数、ウィンドウ数、手法数の積であり、グローバルモデルではウィンドウ数と手法数の積である。回数が予算を超える場合は、部分集合かウィンドウ数を減らす。評価対象のウィンドウは決して減らさない。減らした内容はスコアの横に書き留めておく。そうすれば、読者は同じ条件どうしで比較できる。
  6. 本番で何がうまくいかなくなるか
    • 実践ルール 更新のたびに、スコアを読む前に件数(顧客数、窓数、採点した時間数、拒否した締め切り数、MASE から除いた顧客数)を出力して確認する。そのうえで、顧客ごとの MASE の平均を季節ナイーブと並べて報告する。拒否があれば実行を止め、不足したパネルから作った合計は公表しない。
  7. 本章で下した決定

7. 合計を一致させる

読了まで約35分。3 例。

本章では、30 の顧客の合計需要を 2 通りの方法で予測し、判断窓(decision window)を用いて両者のどちらを採るかを選び、各締め切り時点より前の履歴だけを使ってその合計を顧客ごとの比率に分割する。

講義概要: 7 節
  1. 合計に検算が必要な理由
    • 実践ルール 判断が合計に依存するときは常に、合計を両方の方法で予測する。両者を同じ窓で、合計に対しても各クライアントに対しても採点する。判断の対象となる窓で優れた方法を残し、部分が足し合わさるという理由で合計を採用してはならない。
  2. クライアント別の予測を合計する
    • 実行 total-bottom-up-and-direct.py
    • 実践ルール 時計変更フラグのないすべての時間で、合計の系列がその読み値の和に等しいことを確認したうえで、クライアント別の予測を1時間ごとに合計する。和をとる前に各クライアントに開始規則を適用し、どのクライアントのモデルもそのゼロに当てはめられないようにする。和は点予測として扱い、クライアントの中央値の和を合計の中央値とみなしてはならない。
  3. 合計を直接予測する
    • 実践ルール 合計は、クライアントと同じ特徴量を用い、各基準時点より前の合計自身の履歴から直接予測し、目標のスケーリングは意思決定用の窓で選ぶ。両方の方法に同じ窓を使い、それぞれを合計に対する季節ナイーブ法と比べて評価する。自分で構築した方法だけでなく、両方の方法を報告する。
  4. 二つの総量を比較する
    • 実践ルール 方法は、報告する指標を用いて、判断用ウィンドウで選ぶ。同じ指標を標準のカットオフでも、季節ナイーブと並べて、採点対象時間とスケールとともに報告する。二つのウィンドウ集合が食い違うときは、両方を報告し、どれだけ離れているかを述べ、見栄えのよい方を選ばない。
  5. 総量を比率で分割する
    • 実行 figure-client-daily-profiles.py
    • 実行 total-split-by-share.py
    • 実践ルール 総量を比率で分割するのは、ベースラインとして用いる場合か、クライアントの日内プロファイルが似ている場合に限る。各比率はカットオフ前の履歴から計算し、カットオフ後の読み取り値を変更しても比率が動かないことを確認し、各クライアントをボトムアップと同じ尺度で採点する。そのクライアントに分割を用いるのは、意思決定ウィンドウで分割が勝つ場合に限る。
  6. 本番運用で起こる問題
    • 実践ルール 本番では、再学習のたびに合計をその読み取り値の総和と照合し、合計から顧客が欠けたときは停止し、各配分比と各ウィンドウのスケールに対して汚染検査を実行する。同じウィンドウで、識別子ありと識別子なしの合計の誤差を記録する。ウィンドウ間で結果が食い違うときは、両方を報告し、モデルに有利に見えるほうを選んではならない。
  7. この章で決めたこと

8. 予測の不確実性を定量化する

読了まで約56分。7 例。

この章では、翌日予測のそれぞれに範囲を設け、購入がその予測に頼ってよいかどうかを判断できるようにする。

講義概要: 7 節
  1. なぜ一つの数値では足りないのか
    • 実践ルール 二つの誤差の費用が異なる場合は常に範囲を求め、その水準は、安心できそうに見える数値からではなく、それらの費用から選ぶ。カバレッジは、多数の窓にわたって帯の内側に入った時刻の割合として報告し、ある一日が帯に入る確率としては決して報告しない。
  2. Build intervals from residuals
    • 実行 conformal-three-windows.py
    • 実践ルール Build each band from the residuals of windows that come before its cutoff, and check the coverage it reaches on windows it did not use before you trust it. Read the level a design can reach before you read the coverage. Three residuals per client and hour cannot reach either label, so the fix is a larger calibration set, not a different reading of the output.
  3. 以前のウィンドウで較正する
    • 実行 conformal-decision-windows.py
    • 実行 figure-client-coverage-scaled.py
    • 実行 conformal-earlier-windows.py
    • 実践ルール 評価対象より前にあり、祝日を含まないウィンドウで較正し、残差をプールする前に各クライアントを尺度で割る。設計上の各選択は、報告するウィンドウとは別のウィンドウで行う。帯に用いたウィンドウと残差の数、および評価対象の日に得られたカバレッジを報告する。そのカバレッジが水準に届かない場合も同様である。
  4. Measure coverage on held-out days
    • 実行 total-band-miss-runs.py
    • 実行 figure-total-band-misses.py
    • 実践ルール Report coverage on windows that the calibration never used, with the number of windows and the coverage of each. Keep the same measure in a running log once the forecast runs every day, as Chapter 10 does. Read three scored days as a warning, not as a measurement of the level you were promised.
  5. Choose the level from the cost of error
    • 実行 buy-ahead-level-by-cost.py
    • 実践ルール Set the buy level from the two costs, as tau = cu / (cu + co), fix it before you score the days, and calibrate the total's bands on the total's own residuals. Show the realised cost at other levels as a check, but never move the level to whichever one would have won on the days you score.
  6. 本番運用で起こる問題
  7. 本章で行った決定

9. Prophet と基盤モデルの比較

読了まで約61分。7 例。

この章を終えると、本書の標準的な3つのカットオフに Prophet を当てはめ、記録済みの基盤モデル(Chronos-2)と記録済みのニューラルモデル(NHITS)を読み込み、すべてを同じ実測値に対して1つの MASE の尺度で採点できるようになる。

講義概要: 7 節
  1. Prophet の位置づけ
    • 実践ルール 読者がトレンドと季節性の設定を、読み取れるパラメータとして必要とし、なおかつスコア付けした予測が、スコア付けの前に選んだ判断ウィンドウで季節ナイーブ法を上回る場合に、クライアントごとに Prophet を用いる。区間幅はコードで設定し、既定の 80% 区間は 80% 区間として読み、95% の範囲として読んではならない。被覆率は、モデルが主張する水準に照らして確認する。
  2. Run Prophet on the same cutoffs
    • 実行 prophet-holiday-decision.py
    • 実行 prophet-thirty-clients-backtest.py
    • 実践ルール Set Prophet's seasonality, holidays and interval width in code before you score it, and choose any of them on decision windows, never on the standard cutoffs. Keep the holiday table only if it lowers the MASE on the holiday decision windows. Compare Prophet with seasonal naive and the global model on the same windows and the same scale, and list the clients it loses. Set the seed before each predict, and check that a second run prints the same lines.
  3. Load a recorded foundation model's forecasts
    • 実行 recorded-chronos2-check.py
    • 実践ルール Record a foundation model only with its script, its pinned revision, its package versions and a manifest that hashes every output. Read the recorded outputs in every example, and check the hashes before any score reads them. Check the licence of the weights, not only the licence of the package, and name the model version in any licence sentence.
  4. Score the recordings on the same cutoffs
    • 実行 recorded-chronos2-score.py
    • 実行 recorded-nhits-score.py
    • 実行 figure-chronos-ranges.py
    • 実践ルール Score a recorded forecast on the same windows, the same scale and the same readings as every other model, and name any interpolated quantile wherever its range is reported. Before you read a lead, check what the model was trained on, because a model that saw the scored readings cannot show skill on them. Do not choose a model or a setting on these windows. A recorded forecast with no forecasts on the decision windows cannot be chosen for production until it has them.
  5. ニューラルモデルを記録として扱う理由
    • 実行 recorded-nhits-check.py
    • 実践ルール 依存関係が実行環境の予算を超えるときは、そのモデルを例の実行環境から外し、代わりに記録として扱う。そのモデルのピンは別の requirements ファイルに置く。依存関係を追加する前に、クリーンな環境にインストールし、サイズとパッケージ数がどれだけ増えるかを測定する。依存関係の解決によって固定されたパッケージが変わってしまう場合は、モデルを記録として扱う理由になる。固定するバージョンを変更する理由にはならない。
  6. What goes wrong in production
    • 実践ルール Before any Prophet or recorded forecast is reported, check that the holiday table covers the forecast's years when the table is on, that the interval level is printed beside its coverage, that the recording has a window for every cutoff in use, that its quantiles are in order, and that the model revision matches the one scored. A failed check stops the report, and the report says which check failed.
  7. この章で下した判断

10. 予測を動かし続ける

読了まで約44分。6 例。

予測が毎日動くようになると、問うべきことは、予測の得点が良かったかどうかから、使う日になってもなお通用するかどうかへと変わる。

講義概要: 7 節
  1. Refit on a schedule
    • 実行 refit-cadence-decision.py
    • 実践ルール Choose the refit cadence on ordinary days that come before the held-out week, scored on one scale that was read before the first of those days. Take the cadence with the lower mean MASE, and when the two are close, take the one with fewer refits and say so. Never refit on readings from the day you are forecasting.
  2. 実測値が届く前にすべての予測を記録する
    • 実行 rolling-refit-seven-days.py
    • 実践ルール 各予測の行は、そのカットオフの時点で、それまでに到着した読み取り値から書く。再学習日と 2 つの到着時刻をその横に添える。過去のログを、新しいモデルや実測値から作り直してはならない。ある日の行が失われた場合は、その日をログ上で欠損として記し、後から埋めてはならない。
  3. 実績の到着に合わせてログを採点する
    • 実行 late-fill-decision.py
    • 実践ルール 各日は、その最後の読み値が到着した時点で、そのカットオフでログに記録された予測に対して、章で用いる唯一のスケールを使って採点する。読み値が遅れて到着した場合は、その時点で採点し、ログに数え、ログに記録された予測には手を加えない。カットオフの後に予測を変更してはならない。変更によってスコアが改善する場合でも同様である。
  4. バックテストに対するドリフトの検出
    • 実行 drift-flag-rolling.py
    • 実践ルール 日次MASEが、それ以前のキャリブレーション窓の中央値の2倍を超えた日にフラグを立て、そのうえでカレンダー上の原因が説明するかどうかを問う。原因があるときは、フラグの横にその原因を記録する。説明のつかないフラグが2日続いた場合は、モデルを退役させるかどうかの点検の始まりとして扱い、モデルが壊れている証拠とは決して見なさない。
  5. モデルを退役させる時機を知る
    • 実行 drift-after-a-change.py
    • 実行 figure-drift-flags.py
    • 実践ルール 暦に原因がないままフラグが数日連続して立つとき、または80%バンドが数日にわたり測定値の80%を大きく下回ってしか覆わないときは、早期に再学習し、その契機をログとともに記録する。早期の再学習でフラグが解消しない場合は、モデルを退役させる。固定したライブラリがリリースされたときは、この章の検査をやり直し、新しいバージョンで検査に通るまで固定を維持する。
  6. 本番で起こる問題
    • 実践ルール すべての実行で3つの検査を維持する。各再学習と予測から未来を排除する履歴規則、ログの各行に対する2つの到着検査、そして第3章と第7章のリーク検査である。いずれかが失敗したら、ループを止め、次の予測の前に原因を修正する。履歴やログを手作業で修復してはならない。手作業の修復こそ、これらの検査が捕らえるために存在する種類の変更だからである。
  7. 本章で下した判断

問題バンク

全章の設問と解答を、認証済み教育者向けに提供する。各解答は該当する節に紐づいている。 入手方法