module neuralforecast.utils
Global Variables
- AirPassengers
- unique_id
- ds
- y
- airline1_dummy
- airline2_dummy
function 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.
Args:
n_series(int): Number of series for synthetic panel.freq(str, optional): Frequency of the data, panda’s available frequencies. Defaults to “D”.min_length(int, optional): Minimal length of synthetic panel’s series. Defaults to 50.max_length(int, optional): Maximal length of synthetic panel’s series. Defaults to 500.n_temporal_features(int, optional): Number of temporal exogenous variables for synthetic panel’s series. Defaults to 0.n_static_features(int, optional): Number of static exogenous variables for synthetic panel’s series. Defaults to 0.equal_ends(bool, optional): If True, series finish in the same date stampds. Defaults to False.seed(int, optional): Random seed for reproducibility. Defaults to 0.
pd.DataFrame: Synthetic panel with columns [unique_id,ds,y] and exogenous.
function time_features_from_frequency_str
freq_str(str): Frequency string of the form [multiple][granularity] such as “12H”, “5min”, “1D” etc.
List[TimeFeature]: List of time features appropriate for the frequency.
function 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]
df(pd.DataFrame): DataFrame to augment with calendar features.freq(str, optional): Frequency string for determining which features to add. Defaults to “H”.
Tuple[pd.DataFrame, List[str]]: Tuple of (augmented DataFrame, list of feature column names).
function get_indexer_raise_missing
idx(pd.Index): Index to search in.vals(List[str]): Values to find indices for.
List[int]: List of index positions.
ValueError: If any values are missing from the index.
function add_conformal_distribution_intervals
model_fcsts(np.array): Model forecasts array.cs_df(DFType): DataFrame containing conformal scores.model(str): Model name.cs_n_windows(int): Number of conformal score windows.n_series(int): Number of series.horizon(int): Forecast horizon.level(Optional[List[Union[int, float]]], optional): Confidence levels for prediction intervals. Defaults to None.quantiles(Optional[List[float]], optional): Quantiles for prediction intervals. Defaults to None.
Tuple[np.array, List[str]]: Tuple of (forecasts with intervals, column names).
function add_conformal_error_intervals
model_fcsts(np.array): Model forecasts array.cs_df(DFType): DataFrame containing conformal scores.model(str): Model name.cs_n_windows(int): Number of conformal score windows.n_series(int): Number of series.horizon(int): Forecast horizon.level(Optional[List[Union[int, float]]], optional): Confidence levels for prediction intervals. Defaults to None.quantiles(Optional[List[float]], optional): Quantiles for prediction intervals. Defaults to None.
Tuple[np.array, List[str]]: Tuple of (forecasts with intervals, column names).
function get_prediction_interval_method
method(str): Name of the prediction interval method.
Callable: The corresponding method function.
ValueError: If the method is not supported.
function level_to_quantiles
level(List[Union[int, float]]): List of confidence levels (e.g., [80, 90]).
List[float]: List of corresponding quantiles.
function quantiles_to_level
quantiles(List[float]): List of quantiles (e.g., [0.1, 0.5, 0.9]).
List[Union[int, float]]: List of corresponding confidence levels.
class TimeFeature
method __init__
class SecondOfMinute
Second of minute encoded as value between [-0.5, 0.5].
method __init__
class MinuteOfHour
Minute of hour encoded as value between [-0.5, 0.5].
method __init__
class HourOfDay
Hour of day encoded as value between [-0.5, 0.5].
method __init__
class DayOfWeek
Day of week encoded as value between [-0.5, 0.5].
method __init__
class DayOfMonth
Day of month encoded as value between [-0.5, 0.5].
method __init__
class DayOfYear
Day of year encoded as value between [-0.5, 0.5].
method __init__
class MonthOfYear
Month of year encoded as value between [-0.5, 0.5].
method __init__
class WeekOfYear
Week of year encoded as value between [-0.5, 0.5].
method __init__
class PredictionIntervals
Class for storing prediction intervals metadata information.
method __init__
n_windows(int, optional): Number of windows to evaluate. Defaults to 2.method(str, optional): One of the supported methods for the computation of prediction intervals: conformal_error or conformal_distribution. Defaults to “conformal_distribution”.

