Skip to main content

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

Load Favorita forecasting benchmark dataset. In contrast with other hierarchical datasets, this dataset contains a geographic hierarchy for each individual grocery item series, identified with ‘item_id’ column. The geographic hierarchy is captured by the ‘hier_id’ column. For this reason minor wrangling is needed to adapt it for use with HierarchicalForecast, and StatsForecast libraries. Parameters: Returns: Example:

FavoritaData.load_preprocessed

Load Favorita group datasets. For the exploration of more complex models, we make available the entire information including data at the bottom level of the items sold in Favorita stores, in addition to the aggregate/national level information for the items. Parameters: Returns:

Example

Auxiliary Functions

This auxiliary functions are used to efficiently create and wrangle Favorita’s series.

Numpy Wrangling

numpy_balance

Fast NumPy implementation of ‘balance’ operation. Useful to create a balanced panel dataset, ie a dataset with all the interactions of ‘unique_id’ and ‘ds’. Parameters: Returns:

numpy_ffill

Fast NumPy implementation of 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:
The ffill method would fill the missing values as follows:
Parameters: Returns:

numpy_bfill

Fast NumPy implementation of 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:
The bfill method would fill the missing values as follows:
Parameters: Returns:

one_hot_encoding

Encodes dataFrame’s categorical variables skipping index column. Parameters: Returns:

nested_one_hot_encoding

Encodes dataFrame’s hierarchically-nested categorical variables. Skips the index column. Nested categorical variables (example geographic levels country>state), require the dummy features to preserve encoding order, to reflect the hierarchy of the categorical variables. Parameters: Returns:

get_levels_from_S_df

Get hierarchical index levels implied by aggregation constraints dataframe. Create levels from summation matrix (base, bottom). Goes through the rows until all the bottom level series are ‘covered’ by the aggregation constraints to discover blocks/hierarchy levels. Parameters: Returns:

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

Downloads Favorita Competition Dataset. The dataset weights 980MB, its download is not currently robust to brief interruptions of the process. It is recommended execute with good connection. Parameters: Examples: