

 Amazon Forecast 不再向新买家开放。Amazon Forecast 的现有客户可以继续照常使用该服务。[了解更多](https://aws.amazon.com/blogs/machine-learning/transition-your-amazon-forecast-usage-to-amazon-sagemaker-canvas/)

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 非参数时间序列 (NPTS) 算法
<a name="aws-forecast-recipe-npts"></a>

Amazon Forecast 非参数时间序列 (NPTS) 算法是可扩展的概率基线预测器。它通过从过去的观察中采样来预测给定时间序列的未来值分布。预测受观察的值的限制。当时间序列是间歇性的（或稀疏的，包含许多 0）和突发的时，NPTS 特别有用。例如，预测时间序列具有许多低计数的单个项目的需求。Amazon Forecast 提供 NPTS 的变体，这些变体在所采样的过去的观察及其采样方式上有所不同。要使用 NPTS 变体，请选择超参数设置。

## NPTS 的工作原理
<a name="aws-forecast-recipe-npts-how-it-works"></a>

与经典预测方法（如指数平滑法 (ETS) 和自回归积分滑动平均模型 (ARIMA)）类似，NPTS 分别为每个时间序列生成预测。数据集中的时间序列可以具有不同的长度。观察可用的时间点称为训练范围，需要预测的时间点称为预测范围。

Amazon Forecast NPTS 预测程序具有以下变体：NPTS、季节性 NPTS、气候预测程序以及季节性气候预测程序。

**Topics**
+ [NPTS](#aws-forecast-recipe-npts-variants-npts)
+ [季节性 NPTS](#aws-forecast-recipe-npts-variants-seasonal)
+ [气候预测程序](#aws-forecast-recipe-npts-variants-climatological)
+ [季节性气候预测程序](#aws-forecast-recipe-npts-variants-seasonal-climatological)
+ [季节性特征](#aws-forecast-recipe-npts-seasonal-features)
+ [最佳实践](#aws-forecast-recipe-npts-recommended-practices)

### NPTS
<a name="aws-forecast-recipe-npts-variants-npts"></a>

在该变体中，通过从时间序列的训练范围中的所有观察中采样来生成预测。但是，此变体不是从所有观察中均匀地采样，而是根据与需要预测的当前时间步长的距离，为每个过去的观察分配权重。特别是，它使用的权重根据过去观察的距离呈指数衰减。通过这种方式，来自最近过去的观察结果的采样概率远高于远处过去的观测结果。这就假定，对未来而言，最近的过去比遥远的过去更具指示性。您可以使用 `exp_kernel_weights` 超参数控制权重的衰减量。

要在 Amazon Forecast 中使用此 NPTS 变体，请将 `use_seasonal_model` 超参数设置为 `False` 并接受所有其他默认设置。

### 季节性 NPTS
<a name="aws-forecast-recipe-npts-variants-seasonal"></a>

季节性 NPTS 变体类似于 NPTS，只不过它不从所有观察中采样，而是仅使用来自过去*季节* 的观察。默认情况下，季节由时间序列的粒度确定。例如，对于每小时时间序列，要预测小时 *t*，此变体从对应于前几天的小时 *t* 的观察中采样。与 NPTS 类似，前一天的小时 *t* 处的观察获得的权重高于前几天的小时 *t* 处的观察。有关如何根据时间序列的粒度确定季节性的更多信息，请参阅[季节性特征](#aws-forecast-recipe-npts-seasonal-features)。

### 气候预测程序
<a name="aws-forecast-recipe-npts-variants-climatological"></a>

气候预测程序变体以均匀概率对所有过去的观测结果进行采样。

要使用气候预测程序，请将 `kernel_type` 超参数设置为 `uniform`，并将 `use_seasonal_model` 超参数设置为 `False`。接受所有其他超参数的默认设置。

### 季节性气候预测程序
<a name="aws-forecast-recipe-npts-variants-seasonal-climatological"></a>

与季节性 NPTS 类似，季节性气候预测程序对过去季节的观察进行采样，但以均匀概率对其进行采样。

要使用季节性气候预测程序，请将 `kernel_type` 超参数设置为 `uniform`。接受所有其他超参数的所有其他默认设置。

### 季节性特征
<a name="aws-forecast-recipe-npts-seasonal-features"></a>

要为季节性 NPTS 和季节性气候预测程序确定季节对应的特征，请使用下表中列出的特征。此表根据粒度列出了支持的基本时间频率的派生特征。Amazon Forecast 包含这些特征时间序列，因此您不必提供它们。


****  

| 时间序列的频率 | 用于确定季节性的特征 | 
| --- | --- | 
| 分钟 | minute-of-hour | 
| 小时 | hour-of-day | 
| 天 | day-of-week | 
| 周 | day-of-month | 
| Month | month-of-year | 

### 最佳实践
<a name="aws-forecast-recipe-npts-recommended-practices"></a>

当使用 Amazon Forecast NPTS 算法时，请考虑以下准备数据和实现最佳结果的最佳实践：
+ 由于 NPTS 单独为每个时间序列生成预测，因此，请在调用模型进行预测时提供整个时间序列。此外，接受 `context_length` 超参数的默认值。这会导致算法使用整个时间序列。
+  如果您更改 `context_length`（因为训练数据太长），请确保它足够大并涵盖过去几个季节。例如，对于每日时间序列，此值必须至少为 365 天（前提是您拥有该数据量）。

## NPTS 超参数
<a name="aws-forecast-recipe-npts-hyperparamters"></a>

下表列出了可在 NPTS 算法中使用的超参数。


| 参数名称 | 说明 | 
| --- | --- | 
| context\$1length | 模型用于进行预测的过去时间点的数量。默认情况下，它使用训练范围中的所有时间点。通常，此超参数的值应该很大，并且应涵盖过去几个季节。例如，对于每日时间序列，此值必须至少为 365 天。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/forecast/latest/dg/aws-forecast-recipe-npts.html)  | 
| kernel\$1type | 用于定义用来对过去观察进行采样的权重的内核。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/forecast/latest/dg/aws-forecast-recipe-npts.html)  | 
| exp\$1kernel\$1weights |  仅当 `kernel_type` 为 `exponential` 时才有效。 内核的扩展参数。对于在遥远的过去向观察提供的权重的更快（指数）衰减，使用大的值。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/forecast/latest/dg/aws-forecast-recipe-npts.html)  | 
| use\$1seasonal\$1model | 是否使用季节性变体。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/forecast/latest/dg/aws-forecast-recipe-npts.html)  | 
| use\$1default\$1time\$1features |  仅适用于*季节性 NPTS* 和*季节性气候预测器*变体。 是否根据时间序列的粒度使用季节性特征来确定季节性。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/forecast/latest/dg/aws-forecast-recipe-npts.html)  | 