합계를 맞추기
읽는 데 약 36분분 걸린다, 7절에 2개 예제이(가) 있음.
AI로 번역함. 영어 원문을 사람이 검증함. 우리가 책을 만드는 방식
영어판 2026.11.11판을 번역한 것이다. 원문 읽기
30명 고객의 총수요를 두 가지 방법으로 예측하고, 결정 구간에서 두 방법 중 하나를 선택한 다음, 각 기준 시점 이전의 이력만 사용해 그 총량을 고객별 몫으로 나눈다.
공급사는 하루 전 전력 구매를 고객 한 명 한 명이 아니라 고객 전체의 총수요를 기준으로 단 한 번 결정한다. 6장에서는 고객별로 예측했으며, 총량은 그 예측들을 합산해 만들 수도 있고 따로 예측할 수도 있다. 이 장에서는 두 결과가 일치하는지, 그리고 어느 쪽을 신뢰해야 하는지를 다룬다. 두 방법은 앞서와 같은 구간에서 평가하므로 비교가 공정하다. 예제는 6장의 고객, 구간, 척도를 그대로 사용하므로, 여기에 나오는 모든 수치는 직접 실행해 볼 수 있는 예제가 출력한 것이다.
총량에 점검이 필요한 이유
하나의 양에 대한 두 예측은 서로 다른 경로로 만들어지기 때문에 어긋날 수 있다. 여기서 다루는 양은 매시간 30개 고객 전체(ALL30)의 총수요이다. 한 경로는 30개 고객의 예측을 더한다. 다른 경로는 총량 시계열 하나에 모델 하나를 적합한다. 두 경로는 같은 측정값을 읽지만 각자 다른 방식으로 실패한다. 합산 방식은 모든 고객의 오차를 총량에 그대로 가져온다. 총량 모델은 총량 자체의 패턴만 보므로, 고객별 패턴이 총량 안에서 사라질 수 있다.
이 점검이 중요한 까닭은 공급자가 고객별이 아니라 총량을 기준으로 구매하기 때문이다. 같은 시간에 고객들의 오차가 같은 방향으로 쏠리면, 모든 고객을 잘 예측했더라도 총량은 빗나갈 수 있다. 그래서 이 장은 두 질문을 차례로 던진다. 첫째, 데이터에서 부분의 합이 전체와 일치하는가? 둘째, 중요한 구간에서 총량 예측이 부분의 합보다 나은가?
합이 맞는 예측을 정합적(coherent) 예측이라 한다. Hyndman과 Athanasopoulos의 Forecasting: Principles and Practice, 3판, 11장은 예측을 정합적으로 만드는 여러 방법을 소개하며, 여기서는 두 가지가 중요하다. *상향식(bottom-up)*은 최하위 수준, 곧 고객을 예측한 뒤 결과를 더한다. *하향식(top-down)*은 최상위 수준, 곧 총량을 예측한 뒤 비율에 따라 아래로 나눈다. 이 장은 두 이름을 오직 이 의미로만 사용한다.
정합성은 제약일 뿐 정확도의 척도가 아니다. 합이 맞는 총량도 합이 맞지 않는 총량보다 나쁠 수 있다. 따라서 이 장은 총량과 각 고객을 따로 평가하며, 부분들이 일치한다는 이유로 예측을 받아들이지 않는다.
이 책은 hierarchicalforecast 대신 pandas로 두 총량을 직접 만든다. 계층이 한 단계뿐이어서 각 경로가 한 번의 합산 또는 한 번의 분할로 끝나고, 실행 부담도 작게 유지된다. 두 경로를 최적으로 결합하는 방법도 있다. MinT는 불편성 가정 아래에서 정합적 예측의 평균제곱오차를 최소화하는 정합적 예측을 선택하며, 예측 오차의 공분산 행렬을 사용한다(Wickramasuriya, Athanasopoulos and Hyndman, 2019. 공개된 워킹 페이퍼는 robjhyndman.com/papers/mint.pdf에 있다). 이 행렬을 추정하는 일은 그 자체로 하나의 프로젝트이며, 이 장은 이를 다루지 않는다.
작업 규칙: 결정이 총량에 달려 있을 때마다 총량을 두 방식으로 모두 예측한다. 두 예측을 같은 구간에서, 총량과 각 고객 모두에 대해 평가한다. 결정 구간에서 앞선 방법을 택하며, 부분의 합이 맞는다는 이유로 총량을 받아들이지 않는다.
고객 예측 합산하기
상향식 총계는 6장에서 만든 30개 고객 예측을 시간별로 합한 값이다. 각 기준 시점마다 전역 모델 하나가 래그 24와 168, 그리고 6장에서 유지한 고객 식별자를 사용해 모든 고객의 향후 24시간을 예측한다. 한 시간에 대한 총계의 예측은 그 시간의 30개 값을 합한 것이다. c를 고객, t를 시간이라 하면 규칙은 total(t) = sum over c of forecast(c, t)이다.
합산은 구성상 항상 맞아떨어지므로, 중요한 검사는 데이터에 대한 것이다. 총계 시계열은 모든 시간에서 30개 측정값의 합과 같아야 한다. 그렇지 않으면 모든 점수가 잘못된 수치를 기준으로 측정된다. 예외는 시계 변경 시간이다. 시계 변경 플래그는 해당 고객의 측정값을 결측으로 만들므로, 총계는 2013년 3월 31일과 2014년 3월 30일의 01:00(건너뛰는 시간), 그리고 2013년 10월 27일과 2014년 10월 26일의 01:00(반복되는 시간)에 결측이 된다.
아래의 모든 점수는 총계를 기준으로 측정하므로, 먼저 총계가 그 구성 요소와 일치해야 한다. 첫 번째 예제는 두 총계를 모두 만들어 점수를 매기고, 마지막 줄에서 시계 변경이 없는 각 시간마다 그 일치 여부를 검사한다.
1"""Forecasts the total of the thirty clients two ways, bottom-up (the sum of the client forecasts) and direct (one model on the2total), and chooses between them on the four decision windows by MAE on the total. The choice rests on the two decision-window3MAE lines; the standard cutoffs then report both beside seasonal naive, and the last two lines check the total and the scale."""4import pandas as pd56from lib.baselines import seasonal_scale7from lib.electricity import load8from lib.panel import ALL30, DECISION_CUTOFFS, check_decision_hours9from lib.scoring import actual_hours, score_windows10from lib.settings import EVAL_CUTOFFS, show11from lib.totals import (DIRECT_SCALED, METHODS, TOTAL, direct_windows, plain_mae, pooled_mae, total_checks,12 total_forecasts, total_frame, total_scale_rows)1314raw = load(ALL30)15total = total_frame(raw) # the hourly sum of the thirty clients, after the start rule; missing in a clock-change hour16dec, cut = pd.to_datetime(DECISION_CUTOFFS), pd.to_datetime(EVAL_CUTOFFS)1718dec_actual = actual_hours(total, dec)19# the direct model here uses the target setting the book chose: DIRECT_SCALED is False, so the direct total is unscaled20dec_mae = pooled_mae(dec_actual, total_forecasts(raw, dec), ["bottom-up", "direct"])21# the direct model's MAE with its target scaled (True) and unscaled (False)22direct_setting = {s: pooled_mae(dec_actual, direct_windows(raw, dec, scaled=s), ["direct"])["direct"]23 for s in (True, False)}24# stops the run if the constant no longer names the setting with the lower MAE25if direct_setting[DIRECT_SCALED] != min(direct_setting.values()):26 raise ValueError("DIRECT_SCALED is not the target setting with the lower MAE on the decision windows")27show("decision cutoffs", len(dec))28# raises if a decision hour is a Portuguese holiday or reaches the held-out week; the count is printed for the record29show("decision holiday hours", check_decision_hours(dec_actual))30show("MAE bottom-up, decision windows", dec_mae["bottom-up"])31show("MAE direct, decision windows", dec_mae["direct"])32show("MAE direct with a scaled target, decision windows", direct_setting[True])33show("chosen direct target", "unscaled" if not DIRECT_SCALED else "scaled")34# the bottom-up total without the client identifier, which Chapter 6 also tried35show("MAE bottom-up without identifier, decision windows", plain_mae(raw, dec))36show("chosen total method", dec_mae.idxmin())3738# the scale reads the readings before the first standard cutoff, and no later ones39scale = total_scale_rows(raw, cut[0])40scored, per_client = score_windows(actual_hours(total, cut), total_forecasts(raw, cut), METHODS, scale)41show("scored hours", len(scored))42# seasonal_scale returns one value per unique_id, so [TOTAL] picks the total's43show("MASE scale of the total", seasonal_scale(scale)[TOTAL])44for model in METHODS:45 show(f"MAE {model}", (scored["y"] - scored[model]).abs().mean())46for model in METHODS:47 show(f"MASE {model}", per_client.loc[TOTAL, model])48show("MAE bottom-up without identifier", plain_mae(raw, cut))49# the first cutoff is passed as first_cutoff; the scale check then runs on every cutoff in cut50for label, value in total_checks(raw, cut[0], cut).items():51 show(label, value)
python total-bottom-up-and-direct.pydecision cutoffs: 4
decision holiday hours: 0
MAE bottom-up, decision windows: 1267.47
MAE direct, decision windows: 1678.62
MAE direct with a scaled target, decision windows: 1705.71
chosen direct target: unscaled
MAE bottom-up without identifier, decision windows: 1383.29
chosen total method: bottom-up
scored hours: 72
MASE scale of the total: 2689.26
MAE SeasonalNaive: 3639.41
MAE bottom-up: 2985.88
MAE direct: 3423.11
MASE SeasonalNaive: 1.35
MASE bottom-up: 1.11
MASE direct: 1.27
MAE bottom-up without identifier: 2837.66
clock-free hours where the total differs from the sum of the thirty clients: 0
scale changes after poisoning readings from each scored cutoff: 0
시계 변경 플래그가 없는 모든 시간에서 총계는 30개 고객의 합과 같다. 이 검사에서 총계와 합이 다른 시간은 0개이다.
시계 변경 시간에는 규칙이 하나 더 필요하다. 이 시간에 총계는 결측이지만 예측은 결측이 아니다. 각 예측 구간은 레이블이 붙은 모든 시간에 값을 만들어 내므로, 하류의 표가 채워야 할 빈칸이 출력 격자에 생기지 않는다. 점수 계산은 측정값이 없는 예측 시간을 받아들이지 않으므로, 가려진 시간을 0으로 채점할 수 없다. 이 장에서 채점되는 구간에는 그런 시간이 하나도 없다.
시작 규칙은 합산 전에 각 고객에게 적용된다. 늦게 시작한 고객의 첫 측정값 이전의 0은 수요가 아니므로 규칙이 이를 제외하며, 이는 4장에서 한 고객을 대상으로 보인 바와 같다. 0은 합에 아무것도 더하지 않고 시작하지 않은 고객도 아무것도 더하지 않으므로, 이 규칙은 총계를 바꾸지 않는다. 위의 검사가 이를 보여 준다. 반면 이 규칙은 각 고객 자신의 예측은 바꾼다. 그 0으로 적합된 모델은 이를 낮은 사용량으로 학습하기 때문이다.
상향식 총계는 고객들의 오차를 좋든 나쁘든 그대로 물려받는다. 6장은 표준 기준 시점에서 30개 고객 중 23개 고객에 대해 모델이 계절적 단순 예측을 이기고, 나머지에서는 더 나쁘다는 것을 확인했다. 이 장 뒷부분의 비교는 그 오차 중 얼마가 총계에 도달하는지를 측정한다.
더해지는 것은 평균뿐이다. 기댓값은 선형이므로 합의 평균은 평균의 합이다. 합의 중앙값은 일반적으로 중앙값의 합이 아니며, 다른 분위수도 마찬가지이다. 이들은 오차가 완벽하게 함께 움직이는 경우와 같은 특수한 경우에만 더해진다. 따라서 상향식 총계는 점 예측이다. 고객들의 구간을 더해서 총계의 구간을 만들 수는 없다. 8장에서 구간을 다룰 때 이 문제를 다시 다룬다.
작업 규칙: 시계 변경 플래그가 없는 모든 시간에서 총계 시계열이 측정값의 합과 같은지 확인한 뒤, 고객 예측을 시간별로 합산한다. 합산 전에 각 고객에게 시작 규칙을 적용하여 어떤 고객의 모델도 그 0에 적합되지 않게 한다. 합을 점 예측으로 취급하고, 고객들의 중앙값의 합을 총계의 중앙값으로 삼지 않는다.
이 부분은 아직 번역되지 않았으므로 영어로 표시된다.
Forecast the total directly
The direct total is one model fitted to the total series itself. Its history is the total's history before the cutoff: the readings of the 1,344 hours before it, which is 8 weeks, the same length as the clients' histories. Each client's history is cut by the start rule, its clock-change hours are filled from its own neighbours, as Chapter 3 does, and the readings are summed by hour. The total's history therefore has no missing hour.
The model uses the features the clients use. Its inputs are the total's readings 24 and 168 hours earlier, so no input comes from the day being forecast. Its target is the total as it is, not scaled. Chapter 6 scales each client's target, because one model over clients of different sizes would otherwise fit the large ones. A single total has no such mix, so that reason does not carry over. On the decision windows, the unscaled target has the lower error, 1678.62 kWh against 1705.71 kWh with the target scaled, as the first example shows, so the direct model uses it. The model is fitted once per cutoff, on that cutoff's history only, and it forecasts the next 24 hours. It is a LightGBM regressor inside mlforecast 1.1.0, with the settings of Chapter 5.
The two totals differ in how they are built. The bottom-up total comes from one global model that forecasts every client, and the direct total from one model that forecasts the sum. The lags and the other settings are the same. The target scaling differs, and the decision windows choose it for the direct model alone.
The total is usually smoother than any client, because the clients' peaks partly cancel in the sum. A model fitted to a smoother series has less of its own noise to learn, which can help the direct total. The comparison later in the chapter tests whether it does on these windows, and the answer is not the one the smoothness suggests.
The model sees the total only through its history. It does not see which client a reading came from, or which client moved the total. That is the trade the direct method makes. It gets one smooth series and loses the clients' separate shapes. The bottom-up method keeps those shapes and must add thirty errors together.
Seasonal naive on the total is the baseline that both must beat. It forecasts each hour as the same hour the day before, as in Chapter 2, applied to the total's history. It is scored on the same windows and against the same scale.
Working rule: Forecast the total directly with the clients' features, from the total's own history before each cutoff, and choose the target's scaling on the decision windows. Use the same windows for both methods, and score each against seasonal naive on the total. Report both methods, and not only the one you built.
이 부분은 아직 번역되지 않았으므로 영어로 표시된다.
Compare the two totals
On the four decision windows, the bottom-up total has the lower error, so it is the method chosen. Those windows are Chapter 5's four ordinary days before the held-out week, used only to choose: Nov 25, Nov 26, Dec 2 and Dec 3, 2014. Chapter 6 chose the client identifier on the same days. Each method is scored by MAE on the total, and bottom-up's MAE there is 1267.47 kWh, against 1678.62 kWh for the direct total. The example refuses to run if a decision hour falls on a Portuguese holiday, and it counts 0 such hours.
The standard cutoffs, Dec 29 to Dec 31, 2014, are the report. They are not used to choose. On these three windows the total has 72 scored hours. Its MASE scale is the mean absolute change between readings a day apart, taken over every reading before Dec 29, 2014, with the clock-change hours masked. That is the rule for a MASE scale from Chapter 2, as Chapter 6 applies it to each client, here applied to the total, and it comes to 2689.26 kWh.
| Method | MAE (kWh) | MASE |
|---|---|---|
| Seasonal naive | 3639.41 | 1.35 |
| Bottom-up | 2985.88 | 1.11 |
| Direct | 3423.11 | 1.27 |
MAE and MASE rank the methods alike here. MAE is in kilowatt hours, so it reads as the average cost of an hour's error. MASE divides each error by the same scale, so on one series it is only a constant multiple of MAE. Its use is across series. Chapter 6 needs it to compare clients of very different sizes, and the total sits beside them on the same footing.
On the standard cutoffs the direct total beats seasonal naive on the total, but by a smaller margin than the bottom-up total does, as the MASE column of the table shows.
A method wins on the decision windows when its error is lower there, and the standard cutoffs then either confirm that or contradict it. For the total, the standard cutoffs confirm the choice, since bottom-up is lower on both window sets. That agreement is why the chapter recommends bottom-up for the total, with some confidence. Agreement counts only when the two sets are separate, and they are. The four decision windows all fall before Dec 25, 2014, the first day of the held-out week, and the standard cutoffs are the last three days of that week. No decision reads a standard cutoff.
The identifier is where the two window sets disagree. On the decision windows, the bottom-up total without the identifier has an MAE of 1383.29 kWh, against 1267.47 kWh with it, so the identifier lowers the total's error there, as the per-client MASE in Chapter 6 does on the same windows. On the standard cutoffs the plain total has an MAE of 2837.66 kWh, and the total with the identifier has 2985.88 kWh. The standard cutoffs therefore favour the plain total. The book reports that and does not act on it, because Chapter 6 kept the identifier on per-client MASE, and the decision windows are the ones that choose. A supplier that doubts four decision windows should add decision windows before Dec 25, 2014, and decide again on those, not on the standard cutoffs.
Working rule: Choose a method on the decision windows, by the measure you will report. Report the same measure on the standard cutoffs beside seasonal naive, with the scored hours and the scale. When two window sets disagree, report both, say how far apart they are, and do not pick the one that reads better.
총량을 비중으로 나누기
하향식 분할은 직접 예측한 총량에서 출발해 각 고객에게 그 총량의 일정 비중을 배정한다. 고객의 비중은 그 고객 자신의 이력, 즉 기준 시점 이전 1,344시간의 사용량을 같은 시간 동안의 총량 사용량으로 나눈 값이다. 각 고객의 특정 시간에 대한 하향식 예측은 그 시간에 대한 직접 총량 예측에 고객의 비중을 곱한 값이다. 지난 8주 동안 총량의 10분의 1을 차지한 고객은 다음 날에도 총량의 10분의 1을 차지할 것으로 예상된다.
8주는 조정해서 얻은 값이 아니라 선택한 값이다. 이 장의 다른 모든 모델이 읽는 이력이 8주이므로, 분할도 고객 모델과 같은 기억 길이를 쓴다. 더 짧은 구간을 쓰면 고객 비중의 변화를 더 빨리 따라가지만 잡음이 더 커진다. 이 장은 이 상충 관계를 측정하지 않는다. 이를 알아야 하는 공급자는 의사결정 구간에서 직접 시험해야 한다.
분할의 약점은 하루의 형태이다. 분할은 모든 고객에게 총량의 일일 프로파일을 그대로 부여하므로, 다른 시간대에 정점을 찍는 고객은 총량 예측이 아무리 좋아도 매 시간 잘못된 프로파일을 받는다. 이 고객들에서는 참 총량을 알고 있어도 분할이 진다. 이 장에서 오라클 검사라고 부르는 검사는 어떤 예측도 알 수 없는 실제 총량에 비중을 적용하며, 이때 고객별 MAE의 평균은 171.80 kWh이다. 이는 방법이 아니라 기준이다. 완벽한 총량을 가졌을 때 분할이 갖는 오차이다. 고객마다 예측해야 하는 상향식 예측의 고객별 MAE 평균은 122.81 kWh이다.
비중도 고르지 않다. 첫 번째 기준 시점인 2014년 12월 29일에 가장 큰 고객이 총량에서 차지하는 비중은 0.56이다.
MinT를 정의한 워킹 페이퍼는 Hyndman et al. (2011)을 인용하며, 기저 예측에 편향이 없더라도 하향식 분할은 각 수준의 조정된 예측에 편향을 일으킨다고 보고한다(Wickramasuriya, Athanasopoulos and Hyndman, 2017). 이 장은 그 결과를 다시 유도하지 않는다. 이 고객들에서 분할을 측정하며, 오라클 검사는 분할 자체의 오차에 대한 기준을 제공한다.
같은 구간에서 분할을 상향식과 고객별로 비교해 채점하면, 어느 고객에게서든 분할이 이기는지, 곧 평균으로는 알 수 없는 사실을 알 수 있다. 두 번째 예제가 이를 수행하며, 비중에 대한 누수 검사도 실행한다. 먼저 의사결정 구간에서 선택을 내리고, 그다음 표준 기준 시점의 결과를 보고한다.
1"""Splits the direct total forecast into client forecasts, each client taking its share of the history before each cutoff2(top-down), and compares them with bottom-up on the same windows. The point rests on the mean per-client MASE and MAE lines;3the last line is a leak check that no share reads a reading after its cutoff."""4import pandas as pd56from lib.electricity import load7from lib.panel import ALL30, DECISION_CUTOFFS, check_decision_hours8from lib.settings import EVAL_CUTOFFS, show9from lib.totals import SPLIT_METHODS, client_mae, oracle_split_mae, shares, split_checks, split_scored1011raw = load(ALL30)12dec, cut = pd.to_datetime(DECISION_CUTOFFS), pd.to_datetime(EVAL_CUTOFFS)1314# the third value, the hours the top-down clients don't add up to the direct total (none, by construction), is unused15dec_scored, dec_per, _ = split_scored(raw, dec)16show("decision holiday hours", check_decision_hours(dec_scored))17show("mean per-client MASE bottom-up, decision windows", dec_per["bottom-up"].mean())18show("mean per-client MASE top-down, decision windows", dec_per["top-down"].mean())19show("chosen client method", dec_per.mean().idxmin())2021# the third value is discarded, as above22scored, per_client, _ = split_scored(raw, cut)23show("scored hours", len(scored))24mae = pd.DataFrame({m: client_mae(scored, m) for m in SPLIT_METHODS})25for model in SPLIT_METHODS:26 show(f"mean per-client MAE {model}", mae[model].mean())27for model in SPLIT_METHODS:28 show(f"mean per-client MASE {model}", per_client[model].mean())29show("clients where top-down has the lower MAE", int((mae["top-down"] < mae["bottom-up"]).sum()))30# the split applied to the actual total: a reference, since no forecast can know the total in advance31show("mean per-client MAE with the true total split by share", oracle_split_mae(raw, cut))32# the first standard cutoff, Dec 29, 2014; its shares read only the history before it33# shares read the 1,344 hours (8 weeks) before the cutoff34show("largest client share of the total, first cutoff", shares(raw, cut[0]).max())35# each cutoff's readings from the cutoff on replaced by zero, then by a very large value36for label, value in split_checks(raw, cut).items():37 show(label, value)
python total-split-by-share.pydecision holiday hours: 0
mean per-client MASE bottom-up, decision windows: 0.75
mean per-client MASE top-down, decision windows: 2.37
chosen client method: bottom-up
scored hours: 2160
mean per-client MAE bottom-up: 122.81
mean per-client MAE top-down: 218.95
mean per-client MASE bottom-up: 0.91
mean per-client MASE top-down: 2.59
clients where top-down has the lower MAE: 0
mean per-client MAE with the true total split by share: 171.80
largest client share of the total, first cutoff: 0.56
shares changed after poisoning readings from their cutoff: 0
의사결정 구간에서는 고객 기준으로 상향식이 이긴다. 고객별 MASE의 평균은 상향식이 0.75, 하향식이 2.37이므로 상향식을 선택한다.
표준 기준 시점에서는 킬로와트시 단위의 오차에서도 분할이 더 나쁘다. 2160 고객 시간에 대해 고객별 MAE의 평균은 하향식이 218.95 kWh, 상향식이 122.81 kWh이며, 30개 고객 중 하향식의 MAE가 더 낮은 고객은 0개이다.
고객별 MASE의 평균은 하향식이 2.59, 상향식이 0.91이다. 같은 예측에 대한 6장의 통합 MAE는 122.81 kWh로, 상향식 평균 122.81 kWh와 같다. 이는 우연이 아니다. 모든 고객이 같은 72개의 채점 시간을 가지므로 고객 오차의 평균이 통합 오차와 같기 때문이다.
어떤 비중도 움직이지 않는다. 비중은 기준 시점 이전의 이력만 읽어야 하므로, 누수 검사는 각 기준 시점 이후의 모든 사용량을 한 번은 0으로, 한 번은 매우 큰 값으로 바꾸고 비중을 다시 계산한다. 6개의 비교(세 기준 시점에 두 값) 가운데 비중이 바뀐 것은 0개이다. 어떤 비중이든 기준 시점 이후의 사용량을 읽었다면 큰 값이 그 비중에 들어갔을 것이다. 비중의 합은 1이고, 하향식 고객들의 합은 구성상 모든 시간에서 직접 총량과 같다. 이런 항등식은 실패할 수 없으므로, 이 장은 여기서 실패할 수 있는 유일한 시험인 누수 검사만 센다.
작업 규칙: 총량을 비중으로 나누는 방법은 기준선으로만 쓰거나 고객들의 일일 프로파일이 비슷할 때만 쓴다. 각 비중은 기준 시점 이전의 이력으로 계산하고, 기준 시점 이후의 사용량을 바꿔도 비중이 움직이지 않는지 확인하며, 각 고객을 같은 척도에서 상향식과 비교해 채점한다. 분할이 의사결정 구간에서 이기는 고객에 한해서만 그 고객에 분할을 유지한다.
이 부분은 아직 번역되지 않았으므로 영어로 표시된다.
What goes wrong in production
Most failures in this chapter are silent.
The first is a quietly short total. If one client drops out of the sum, the total is smaller than the demand, and its scores still look reasonable. The bottom-up total in this book raises an error when an hour has fewer than thirty client forecasts. The start rule refuses a client with too little history instead of skipping it, as Chapter 6 explains. In production, a run that builds fewer forecasts than clients should stop and name the missing client.
The second is the raw sum. The October repeat hour holds the energy of two (Chapter 3), so a total built from raw readings can count that hour at roughly twice its neighbours. The result is a demand spike that is not there. The book's total masks the hour instead, and the check in the first example excludes the clock-change hours for the same reason.
The third is a split that reads the future. A split whose shares use the window's own readings scores better in a backtest than it will in production. The poisoning check is the test. A share must not move when readings after its cutoff change. A production run should keep both checks, the share check in the second example and the scale check in the first, as tests that fail loudly.
The fourth is a decision and a report that disagree. The identifier lowers the total's error on the decision windows and raises it on the standard cutoffs. A monitor that watches only one set of windows will miss the other's failure. On every refit, log the total's error with and without the identifier on the same windows, beside the per-client MASE that Chapter 6 uses to decide.
The fifth is a share that goes stale. A share is a fact about the past 8 weeks, so when a client's habits change, its share lags the change for as long as the window is long. A top-down forecast of that client is then wrong in a steady direction, not at random, and the error does not show in the total at all, because the shares still add to one. A monitor should therefore watch each client's share over time, not only the total's error. The per-client MASE in the second example is the measure that sees it.
The sixth is a scale that moves with the window. The total's MASE scale is read once, from the history before the first scored cutoff. A scale refreshed for each window reads that window's own readings, and every score on the total then changes for reasons that have nothing to do with the forecast. The first example checks, for each scored cutoff, that the scale for that window does not move when readings from the cutoff on are replaced. No scale moves: 0 of the six comparisons (three cutoffs by two values) changes it.
Working rule: In production, check the total against the sum of its readings on every refit, stop when a client is missing from a total, and run the poisoning check on each share and on the scale for each window. Log the total's error with and without the identifier on the same windows. When the windows disagree, report both and do not choose the one that flatters the model.
이 장이 내린 결정
- 총량은
ALL30의 시간별 합이다. 각 고객은 합산 전에 시작 규칙으로 잘라 내며, 어떤 고객이든 해당 시간의 측정값이 시계 변경 시간으로 마스킹되어 있으면 그 시간은 결측으로 둔다. 이 합은 시작 규칙에 따라 달라지지 않으며, 첫 번째 예제의 검사에서 이를 확인할 수 있다. - 모든 예측 시간에는 값이 있으며, 채점은 마스킹된 시간을 거부한다. 출력 격자는 시계 변경 시간을 지나서도 완전하며, 결측된 측정값을 0으로 채점하는 일은 없다.
- 두 총량은 모두 pandas로 직접 구성한다. 계층이 한 단계뿐이므로 각 경로는 합 하나 또는 분할 하나로 끝난다.
hierarchicalforecast와 MinT는 언급만 하고 사용하지 않는다. - 총량은 상향식으로 예측한다. 상향식은 네 개의 결정 구간과 표준 기준 시점에서 MAE가 더 낮다. 직접 예측한 총량은 그 옆에 함께 보고한다.
- 직접 예측하는 총량의 목표값은 스케일링하지 않는다. 결정 구간에서 MAE가 더 낮은 쪽이 이 설정이므로, 고객별 모델과 달리 직접 모델은 목표값을 스케일링하지 않는다. 첫 번째 예제는 두 설정을 모두 출력한다.
- 식별자는 6장이 고객별 모델에 대해 결정한 대로 상향식 총량에 남겨 둔다. 표준 기준 시점에서 총량이 치르는 비용은 앞에서 보고했으며, 이 결정을 뒤집지 않는다.
- 분할은 고객별 방법이 아니다. 결정 구간에서 고객별 MASE는 상향식이 더 낮고, 이 고객들에서는 실제 총량을 사용해도 분할의 성능이 더 나쁘다.
- 비중은 고객별 모델과 같은 이력인, 각 기준 시점 이전 1,344시간에서 구한다. 오염 검사는 어떤 비중도 이후의 측정값을 읽지 않음을 보여 준다.
- 총량의 MASE 척도는 2장의 규칙을 총량에 적용한 것이다. 즉 첫 번째 채점 기준 시점 이전의 모든 측정값에 대한 계절 나이브 오차이며, 시계 변경 시간은 마스킹하고 시작 규칙은 먼저 각 고객에 적용한다.
- 구간은 6장의 것을 따른다. 결정 구간과 표준 기준 시점은 같은 날짜이므로, 두 장의 수치를 한 줄씩 대조할 수 있다.
- 8장은 점 예측을 받는다. 각 고객과 총량에 대한 상향식 예측을 받으며, 대안으로 직접 예측한 총량이 함께 간다. 총량의 구간은 고객별 구간으로 구성할 수 없다.
이 판의 이 장
2026.11.11판예제 통과 2026년 11월 20이 장에서 2개 예제개 중 2개가 통과한다
영어판 2026.11.11판을 번역한 것이다.