core.NeuralForecast class allows you to efficiently fit multiple
NeuralForecast models for large sets of time series. It operates with pandas DataFrame df that identifies individual series and datestamps with the unique_id and ds columns, and the y column denotes the target time
series variable. To assist development, we declare useful datasets that we use throughout all NeuralForecast’s unit tests.
1. Synthetic Panel Data
generate_series
n_series of frequency freq of different lengths in the interval [min_length, max_length].
If n_temporal_features > 0, then each serie gets temporal features with random values.
If n_static_features > 0, then a static dataframe is returned along the temporal dataframe.
If equal_ends == True then all series end at the same date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_series | int | Number of series for synthetic panel. | required |
freq | str | Frequency of the data, panda’s available frequencies. Defaults to “D”. | ’D’ |
min_length | int | Minimal length of synthetic panel’s series. Defaults to 50. | 50 |
max_length | int | Maximal length of synthetic panel’s series. Defaults to 500. | 500 |
n_temporal_features | int | Number of temporal exogenous variables for synthetic panel’s series. Defaults to 0. | 0 |
n_static_features | int | Number of static exogenous variables for synthetic panel’s series. Defaults to 0. | 0 |
equal_ends | bool | If True, series finish in the same date stamp ds. Defaults to False. | False |
seed | int | Random seed for reproducibility. Defaults to 0. | 0 |
| Type | Description |
|---|---|
DataFrame | pd.DataFrame: Synthetic panel with columns [unique_id, ds, y] and exogenous. |
2. AirPassengers Data
The classic Box & Jenkins airline data. Monthly totals of international airline passengers, 1949 to 1960. It has been used as a reference on several forecasting libraries, since it is a series that shows clear trends and seasonalities it offers a nice opportunity to quickly showcase a model’s predictions performance.3. Panel AirPassengers Data
Extension to classic Box & Jenkins airline data. Monthly totals of international airline passengers, 1949 to 1960. It includes two series with static, temporal and future exogenous variables, that can help to explore the performance of models likeNBEATSx
and
TFT.
4. Time Features
We have developed a utility that generates normalized calendar features for use as absolute positional embeddings in Transformer-based models. These embeddings capture seasonal patterns in time series data and can be easily incorporated into the model architecture. Additionally, the features can be used as exogenous variables in other models to inform them of calendar patterns in the data.References
augment_calendar_df
- Q - [month]
- M - [month]
- W - [Day of month, week of year]
- D - [Day of week, day of month, day of year]
- B - [Day of week, day of month, day of year]
- H - [Hour of day, day of week, day of month, day of year]
- T - [Minute of hour*, hour of day, day of week, day of month, day of year]
- S - [Second of minute, minute of hour, hour of day, day of week, day of month, day of year]
Returns:
| Type | Description |
|---|---|
| Tuple[pd.DataFrame, List[str]]: Tuple of (augmented DataFrame, list of feature column names). |
time_features_from_frequency_str
| Name | Type | Description | Default |
|---|---|---|---|
freq_str | str | Frequency string of the form [multiple][granularity] such as “12H”, “5min”, “1D” etc. | required |
| Type | Description |
|---|---|
List[TimeFeature] | List[TimeFeature]: List of time features appropriate for the frequency. |
WeekOfYear
Bases: TimeFeature
Week of year encoded as value between [-0.5, 0.5].
MonthOfYear
Bases: TimeFeature
Month of year encoded as value between [-0.5, 0.5].
DayOfYear
Bases: TimeFeature
Day of year encoded as value between [-0.5, 0.5].
DayOfMonth
Bases: TimeFeature
Day of month encoded as value between [-0.5, 0.5].
DayOfWeek
Bases: TimeFeature
Day of week encoded as value between [-0.5, 0.5].
HourOfDay
Bases: TimeFeature
Hour of day encoded as value between [-0.5, 0.5].
MinuteOfHour
Bases: TimeFeature
Minute of hour encoded as value between [-0.5, 0.5].
SecondOfMinute
Bases: TimeFeature
Second of minute encoded as value between [-0.5, 0.5].
TimeFeature
get_indexer_raise_missing
Returns:
Raises:
| Type | Description |
|---|---|
ValueError | If any values are missing from the index. |
5. Prediction Intervals
PredictionIntervals
PredictionIntervals.method
PredictionIntervals.n_windows
add_conformal_distribution_intervals
| Name | Type | Description | Default |
|---|---|---|---|
model_fcsts | array | Model forecasts array. | required |
cs_df | DFType | DataFrame containing conformal scores. | required |
model | str | Model name. | required |
cs_n_windows | int | Number of conformal score windows. | required |
n_series | int | Number of series. | required |
horizon | int | Forecast horizon. | required |
level | Optional[List[Union[int, float]]] | Confidence levels for prediction intervals. Defaults to None. | None |
quantiles | Optional[List[float]] | Quantiles for prediction intervals. Defaults to None. | None |
add_conformal_error_intervals
| Name | Type | Description | Default |
|---|---|---|---|
model_fcsts | array | Model forecasts array. | required |
cs_df | DFType | DataFrame containing conformal scores. | required |
model | str | Model name. | required |
cs_n_windows | int | Number of conformal score windows. | required |
n_series | int | Number of series. | required |
horizon | int | Forecast horizon. | required |
level | Optional[List[Union[int, float]]] | Confidence levels for prediction intervals. Defaults to None. | None |
quantiles | Optional[List[float]] | Quantiles for prediction intervals. Defaults to None. | None |
get_prediction_interval_method
| Name | Type | Description | Default |
|---|---|---|---|
method | str | Name of the prediction interval method. | required |
| Name | Type | Description |
|---|---|---|
Callable | The corresponding method function. |
| Type | Description |
|---|---|
ValueError | If the method is not supported. |
quantiles_to_level
level_to_quantiles
Returns:

