Skip to main content

Other

Hourly

Daily

Weekly

Monthly

Quarterly

Yearly

Download data class

M4

M4.async_download

Download M4 Dataset. Parameters:
NameTypeDescriptionDefault
directorystrDirectory path to download dataset.required
Example:

M4.download

Download M4 Dataset. Parameters:
NameTypeDescriptionDefault
directorystrDirectory path to download dataset.required
groupstrName of the group to download. If None, downloads all. Defaults to None.None

M4.load

Downloads and loads M4 data. Parameters:
NameTypeDescriptionDefault
directorystrDirectory where data will be downloaded.required
groupstrGroup name. Allowed groups: ‘Yearly’, ‘Quarterly’, ‘Monthly’, ‘Weekly’, ‘Daily’, ‘Hourly’.required
cacheboolIf True saves and loadsTrue
Returns:
TypeDescription
Tuple[DataFrame, Optional[DataFrame], Optional[DataFrame]]Tuple[pd.DataFrame, Optional[pd.DataFrame], Optional[pd.DataFrame]]: Target time series with columns [‘unique_id’, ‘ds’, ‘y’], Static exogenous variables with columns [‘unique_id’, ‘ds’], and static variables.

Evaluation class

M4Evaluation

M4Evaluation.evaluate

Evaluates y_hat according to M4 methodology. Parameters:
NameTypeDescriptionDefault
directorystrDirectory where data will be downloaded.required
groupstrGroup name. Allowed groups: ‘Yearly’, ‘Quarterly’, ‘Monthly’, ‘Weekly’, ‘Daily’, ‘Hourly’.required
y_hatUnion[ndarray, str]Group forecasts as numpy array or benchmark url from https://github.com/Nixtla/m4-forecasts/tree/master/forecasts.required
Returns:
TypeDescription
DataFramepd.DataFrame: DataFrame with columns OWA, SMAPE, MASE and group as index.
Examples:

M4Evaluation.load_benchmark

Downloads and loads a bechmark forecasts. Parameters:
NameTypeDescriptionDefault
directorystrDirectory where data will be downloaded.required
groupstrGroup name. Allowed groups: ‘Yearly’, ‘Quarterly’, ‘Monthly’, ‘Weekly’, ‘Daily’, ‘Hourly’.required
source_urlstrOptional benchmark url obtained from https://github.com/Nixtla/m4-forecasts/tree/master/forecasts. If None returns Naive2.None
Returns:
TypeDescription
ndarraynp.ndarray: Numpy array of shape (n_series, horizon).

URL-based evaluation

The method evaluate from the class M4Evaluation can receive a url of a benchmark uploaded to the M4 competiton. The results compared to the on-the-fly evaluation were obtained from the official evaluation.

Numpy-based evaluation

Also the method evaluate can recevie a numpy array of forecasts.