Hierarchical loss = (1 x loss) +
(temporal total weight x temporal total loss) +
(group total weight x group total loss) +
(group temporal total weight x group temporal total loss)
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-07。"],[],[],null,["# Reduce forecasting bias with hierarchical aggregation\n\n| To see an example of how to create hierarchical forecasting models using AutoML\n| and perform batch prediction,\n| run the \"AutoML training hierarchical forecasting for batch prediction\" notebook in one of the following\n| environments:\n|\n| [Open in Colab](https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_forecasting_hierarchical_batch.ipynb)\n|\n|\n| \\|\n|\n| [Open in Colab Enterprise](https://console.cloud.google.com/vertex-ai/colab/import/https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fvertex-ai-samples%2Fmain%2Fnotebooks%2Fofficial%2Fautoml%2Fsdk_automl_forecasting_hierarchical_batch.ipynb)\n|\n|\n| \\|\n|\n| [Open\n| in Vertex AI Workbench](https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fvertex-ai-samples%2Fmain%2Fnotebooks%2Fofficial%2Fautoml%2Fsdk_automl_forecasting_hierarchical_batch.ipynb)\n|\n|\n| \\|\n|\n| [View on GitHub](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_forecasting_hierarchical_batch.ipynb)\n\nThis page explains hierarchical forecasting, its objectives,\nand shows training strategies you can employ to reduce bias in\nyour forecasting models.\n\nFor detailed instructions on how to configure hierarchical forecasting when\ntraining your forecasting model using the API, see\n[Train a forecast model](/vertex-ai/docs/tabular-data/forecasting/train-model#api).\n\nWhat is hierarchical forecasting\n--------------------------------\n\nTime series are often structured in a nested hierarchy. For example, a\nretailer's entire inventory of products can be divided into categories\nof products. The categories can be further divided into individual\nproducts. When forecasting future sales, the forecasts for a category's products\nmust add up to the forecast for the category itself, and so forth up\nthe hierarchy.\n\nSimilarly, a single time series' time dimension can also exhibit a\nhierarchy. For example, forecasted sales for an individual product at the day\nlevel must add up to the product's forecasted weekly sales. The following\nfigure shows this group and temporal hierarchy as a matrix:\n\nHierarchical forecasting has three objectives:\n\n- **Reduce overall bias** to improve metrics over all time series (total sales).\n- **Reduce temporal bias** to improve metrics over the horizon (season sales).\n- **Reduce group level bias** to improve metrics over a group of time series (item sales).\n\nIn Vertex AI, hierarchical forecasting takes into account the\nhierarchical structure of time series by incorporating additional\n\nterms for aggregated inferences. \n\n Hierarchical loss = (1 x loss) +\n (temporal total weight x temporal total loss) +\n (group total weight x group total loss) +\n (group temporal total weight x group temporal total loss)\n\nFor example, if the hierarchical group is\n\"category\", the inferences at the \"category\" level are the sum of inferences\nfor all \"products\" in the category. If the model's objective is mean\nabsolute error (MAE), the loss includes the MAE for inferences at both the\n\"product\" and \"category\" levels. This helps improve the consistency of\nforecasts at different levels of the hierarchy, and in some cases, might even\nimprove metrics at the lowest level.\n\nConfigure hierarchical aggregation for model training\n-----------------------------------------------------\n\nConfigure hierarchical aggregation when training your forecast models by\nconfiguring\n[`AutoMLForecastingTrainingJob`](/python/docs/reference/aiplatform/latest/google.cloud.aiplatform.AutoMLForecastingTrainingJob)\nin the\n[Vertex AI SDK](/vertex-ai/docs/start/client-libraries)\nor by\n[configuring `hierarchyConfig` in the Vertex AI API](/vertex-ai/docs/tabular-data/forecasting/train-model#api).\n\nAvailable parameters for `AutoMLForecastingTrainingJob` and `hierarchyConfig`\ninclude:\n\n- `group_columns`\n- `group_total_weight`\n- `temporal_total_weight`\n- `group_temporal_total_weight`\n\nThe parameters allow different combinations of group and time aggregated\nlosses. They also allow you to assign weights to increase the priority of\nminimizing the aggregated loss relative to the individual loss. For example, if\nthe weight is `2.0`, it is weighted twice as much as the individual loss.\n\n### `group_columns`\n\nColumn names in your training input table identify the grouping for the\nhierarchy level. The column(s) must be `time_series_attribute_columns`. If you don't set the\ngroup column, all time series are treated as part of the same\ngroup and aggregate over all time series.\n\n### `group_total_weight`\n\nWeight of the group aggregated loss relative to the individual loss. Disabled if\nset to `0.0` or not set.\n\n### `temporal_total_weight`\n\nWeight of the time aggregated loss relative to the individual loss. Disabled if\nset to `0.0` or not set.\n\n### `group_temporal_total_weight`\n\nWeight of the total (group x time) aggregated loss relative to the individual\nloss. Disabled if set to `0.0` or not set. If you don't set the group column,\nall time series are treated as part of the same group and aggregate over\nall time series.\n\nStrategies to reduce bias\n-------------------------\n\nStart with one type of aggregation (group or time) with a weight of\n`10.0`, and then halve or double the value based on the results.\n\n### Reduce overall bias\n\nIn fine-grained forecasts for distributing stock across stores where weighted\nabsolute percentage error (WAPE) at the product x store x date level are used as\na forecasting metric, forecasts often underpredict at the aggregate levels. To\ncompensate for this overall bias, try the following:\n\n- Set `group_total_weight` to `10.0`.\n- Leave `group_columns` unset.\n- Leave other weights unset.\n\nThis aggregates over all time series and reduces overall bias.\n\n### Reduce temporal bias\n\nIn long term planning, forecasts might be made at a product x region x week\nlevel, but the relevant metrics might be measured with respect to seasonal totals.\nTo compensate for this temporal bias, try the following:\n\n- Set `temporal_total_weight` to `10.0`.\n- Leave `group_columns` unset.\n- Leave other weights unset.\n\nThis aggregates over all dates in a time series' horizon, and reduces\ntemporal bias.\n\n### Reduce group level bias\n\nFor forecasts that are multi-purpose in the replenishment process, fine-grained\nforecasts at the product x store x date or week level might aggregate up to\nproduct x distribution center x date levels for distribution or product category\nx date levels for materials orders. To do this, perform the following:\n\n- Set `group_total_weight` to `10.0`.\n- Set `group_columns`, for example, \\[\"region\"\\] or \\[\"region\", \"category\"\\]. Setting multiple group columns uses their combined value to define the group. For best results, use group columns with 100 or fewer distinct combined values.\n- Leave other weights unset.\n\nThis aggregates over all time series in the same group for the same date, and\nreduces bias at the group level.\n\nLimits\n------\n\n- Only one level of time series aggregation is supported. If you specify more than one grouping column, such as \"product, store\", the time series is in the same group only if they share the same values of both \"product\" and \"store\".\n- We recommend using 100 or fewer groups.\n\nWhat's next\n-----------\n\n- [Evaluate your model](/vertex-ai/docs/tabular-data/forecasting/evaluate-model)."]]