FavoritaData
Favorita Data.
The processed Favorita dataset of grocery contains item sales daily history with additional
information on promotions, items, stores, and holidays, containing 371,312 series from
January 2013 to August 2017, with a geographic hierarchy of states, cities, and stores.
This wrangling matches that of the DPMN paper.
References:
FavoritaData.load
| Name | Type | Description | Default |
|---|---|---|---|
directory | str | Directory where data will be downloaded and saved. | required |
group | str | Dataset group name in ‘Favorita200’, ‘Favorita500’, ‘FavoritaComplete’. | required |
cache | bool | If True saves and loads. Defaults to True. | True |
verbose | bool | Whether or not print partial outputs. Defaults to False. | False |
| Name | Type | Description |
|---|---|---|
tuple | A tuple containing: - Y_df (pd.DataFrame): Target base time series with columns [‘item_id’, ‘hier_id’, ‘ds’, ‘y’]. - S_df (pd.DataFrame): Hierarchical constraints dataframe of size (base, bottom). - tags (dict): Dictionary with hierarchical level information. |
FavoritaData.load_preprocessed
| Name | Type | Description | Default |
|---|---|---|---|
directory | str | Directory where data will be downloaded and saved. | required |
group | str | Dataset group name in ‘Favorita200’, ‘Favorita500’, ‘FavoritaComplete’. | required |
cache | bool | If True saves and loads. Defaults to True. | True |
verbose | bool | Whether or not print partial outputs. Defaults to False. | False |
| Name | Type | Description |
|---|---|---|
tuple | Tuple[DataFrame, DataFrame, DataFrame, DataFrame] | A tuple containing: - static_bottom (pd.DataFrame): Static variables of bottom level series. - static_agg (pd.DataFrame): Static variables of aggregate level series. - temporal_bottom (pd.DataFrame): Temporal variables of bottom level series. - temporal_agg (pd.DataFrame): Temporal variables of aggregate level series. |
Example
Auxiliary Functions
This auxiliary functions are used to efficiently create and wrangle Favorita’s series.Numpy Wrangling
numpy_balance
| Name | Type | Description | Default |
|---|---|---|---|
*arrs | NumPy arrays. | () |
| Type | Description |
|---|---|
ndarray | NumPy array with balanced combinations. |
numpy_ffill
ffill that fills missing values.
Fills missing values in an array by propagating the last non-missing value forward.
For example, if the array has the following values:
ffill method would fill the missing values as follows:
| Name | Type | Description | Default |
|---|---|---|---|
arr | ndarray | NumPy array. | required |
| Type | Description |
|---|---|
ndarray | NumPy array with forward-filled values. |
numpy_bfill
bfill that fills missing values.
Fills missing values in an array by propagating the last non-missing value backwards.
For example, if the array has the following values:
bfill method would fill the missing values as follows:
| Name | Type | Description | Default |
|---|---|---|---|
arr | ndarray | NumPy array. | required |
| Type | Description |
|---|---|
ndarray | NumPy array with backward-filled values. |
one_hot_encoding
Returns:
| Type | Description |
|---|---|
DataFrame | DataFrame with one hot encoded categorical columns. |
nested_one_hot_encoding
Returns:
| Type | Description |
|---|---|
DataFrame | DataFrame with one hot encoded hierarchically-nested categorical columns. |
get_levels_from_S_df
| Name | Type | Description | Default |
|---|---|---|---|
S_df | DataFrame | Summing matrix of size (base, bottom), see aggregate method. | required |
| Name | Type | Description |
|---|---|---|
levels | list | Hierarchical aggregation indexes, where each entry is a level. |
distance_to_holiday
make_holidays_distance_df
CodeTimer
Favorita200
Favorita500
FavoritaComplete
FavoritaRawData
Favorita Raw Data.
Raw subset datasets from the Favorita 2018 Kaggle competition.
This class contains utilities to download, load and filter portions of the dataset.
If you prefer, you can also download original dataset available from Kaggle directly:
FavoritaRawData.download
| Name | Type | Description | Default |
|---|---|---|---|
directory | str | Directory where data will be downloaded. | required |

