

 Amazon Forecast is no longer available to new customers. Existing customers of Amazon Forecast can continue to use the service as normal. [Learn more"](https://aws.amazon.com/blogs/machine-learning/transition-your-amazon-forecast-usage-to-amazon-sagemaker-canvas/)

# Non-Parametric Time Series (NPTS) Algorithm
<a name="aws-forecast-recipe-npts"></a>

The Amazon Forecast Non-Parametric Time Series (NPTS) algorithm is a scalable, probabilistic baseline forecaster. It predicts the future value distribution of a given time series by sampling from past observations. The predictions are bounded by the observed values. NPTS is especially useful when the time series is intermittent (or sparse, containing many 0s) and bursty. For example, forecasting demand for individual items where the time series has many low counts. Amazon Forecast provides variants of NPTS that differ in which of the past observations are sampled and how they are sampled. To use an NPTS variant, you choose a hyperparameter setting.

## How NPTS Works
<a name="aws-forecast-recipe-npts-how-it-works"></a>

Similar to classical forecasting methods, such as exponential smoothing (ETS) and autoregressive integrated moving average (ARIMA), NPTS generates predictions for each time series individually. The time series in the dataset can have different lengths. The time points where the observations are available are called the training range and the time points where the prediction is desired are called the prediction range.

Amazon Forecast NPTS forecasters have the following variants: NPTS, seasonal NPTS, climatological forecaster, and seasonal climatological forecaster.

**Topics**
+ [NPTS](#aws-forecast-recipe-npts-variants-npts)
+ [Seasonal NPTS](#aws-forecast-recipe-npts-variants-seasonal)
+ [Climatological Forecaster](#aws-forecast-recipe-npts-variants-climatological)
+ [Seasonal Climatological Forecaster](#aws-forecast-recipe-npts-variants-seasonal-climatological)
+ [Seasonal Features](#aws-forecast-recipe-npts-seasonal-features)
+ [Best Practices](#aws-forecast-recipe-npts-recommended-practices)

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

In this variant, predictions are generated by sampling from all observations in the training range of the time series. However, instead of uniformly sampling from all of the observations, this variant assigns weight to each of the past observations according to how far it is from the current time step where the prediction is needed. In particular, it uses weights that decay exponentially according to the distance of the past observations. In this way, the observations from the recent past are sampled with much higher probability than the observations from the distant past. This assumes that the near past is more indicative for the future than the distant past. You can control the amount of decay in the weights with the `exp_kernel_weights` hyperparameter.

To use this NPTS variant in Amazon Forecast, set the `use_seasonal_model` hyperparameter to `False` and accept all other default settings.

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

The seasonal NPTS variant is similar to NPTS except that instead of sampling from all of the observations, it uses only the observations from the past *seasons *. By default, the season is determined by the granularity of the time series. For example, for an hourly time series, to predict for hour *t*, this variant samples from the observations corresponding to the hour *t* on the previous days. Similar to NPTS, observation at hour *t* on the previous day is given more weight than the observations at hour *t* on earlier days. For more information about how to determine seasonality based on the granularity of the time series, see [Seasonal Features](#aws-forecast-recipe-npts-seasonal-features).

### Climatological Forecaster
<a name="aws-forecast-recipe-npts-variants-climatological"></a>

The climatological forecaster variant samples all of the past observations with uniform probability. 

To use the climatological forecaster, set the `kernel_type` hyperparameter to `uniform` and the `use_seasonal_model` hyperparameter to `False`. Accept the default settings for all other hyperparameters.

### Seasonal Climatological Forecaster
<a name="aws-forecast-recipe-npts-variants-seasonal-climatological"></a>

Similar to seasonal NPTS, the seasonal climatological forecaster samples the observations from past seasons, but samples them with uniform probability. 

To use the seasonal climatological forecaster, set the `kernel_type` hyperparameter to `uniform`. Accept all other default settings for all of the other hyperparameters.

### Seasonal Features
<a name="aws-forecast-recipe-npts-seasonal-features"></a>

To determine what corresponds to a season for the seasonal NPTS and seasonal climatological forecaster, use the features listed in the following table. The table lists the derived features for the supported basic time frequencies, based on granularity. Amazon Forecast includes these feature time series, so you don't have to provide them.


****  

| Frequency of the Time Series | Feature to Determine Seasonality | 
| --- | --- | 
| Minute | minute-of-hour | 
| Hour | hour-of-day | 
| Day | day-of-week | 
| Week | day-of-month | 
| Month | month-of-year | 

### Best Practices
<a name="aws-forecast-recipe-npts-recommended-practices"></a>

When using the Amazon Forecast NPTS algorithms, consider the following best practices for preparing the data and achieving optimal results:
+ Because NPTS generates predictions for each time series individually, provide the entire time series when calling the model for prediction. Also, accept the default value of the `context_length` hyperparameter. This causes the algorithm to use the entire time series. 
+  If you change the `context_length` (because the training data is too long), make sure it is large enough and covers multiple past seasons. For example, for a daily time series, this value must be at least 365 days (provided that you have that amount of data). 

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

The following table lists the hyperparameters that you can use in the NPTS algorithm.


| Parameter Name | Description | 
| --- | --- | 
| context\$1length | The number of time-points in the past that the model uses for making the prediction. By default, it uses all of the time points in the training range. Typically, the value for this hyperparameter should be large and should cover multiple past seasons. For example, for the daily time series this value must be at least 365 days. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/forecast/latest/dg/aws-forecast-recipe-npts.html)  | 
| kernel\$1type | The kernel to use to define the weights used for sampling past observations. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/forecast/latest/dg/aws-forecast-recipe-npts.html)  | 
| exp\$1kernel\$1weights |  Valid only when `kernel_type` is `exponential`. The scaling parameter of the kernel. For faster (exponential) decay in the weights given to the observations in the distant past, use a large value. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/forecast/latest/dg/aws-forecast-recipe-npts.html)  | 
| use\$1seasonal\$1model | Whether to use a seasonal variant. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/forecast/latest/dg/aws-forecast-recipe-npts.html)  | 
| use\$1default\$1time\$1features |  Valid only for the *seasonal NPTS* and *seasonal climatological forecaster* variants. Whether to use seasonal features based on the granularity of the time series to determine seasonality. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/forecast/latest/dg/aws-forecast-recipe-npts.html)  | 