The goal of this project to predict total daily sales of products sold at Favorita stores located in Ecuador. The training data includes dates, store and product information, whether that item was being promoted, as well as the sales numbers. Additional files include supplementary information that may be useful in building the models. Data was adapted from Kaggle.
This project encompasses a comprehensive range of tasks typically encountered in a data science workflow, including data acquisition, feature engineering, data transformation, data visualization & EDA, hypothesis testing, model development, and Streamlit deployment.
User Path:
- data: Includes: 1) store_sales_raw.csv, 2) holidays_events.csv, 3) stores.csv
- notebooks: Includes: 1) store_sales_forecast.ipynb
- models: Includes: 1) sarima_model.joblib, 2) prophet_model.joblib
- outputs: Includes: 1) SARIMA_sales_forecast.xlsx, 2) prophet_sales_forecast.xlsx
- images: Includes the main visualizations and insights from the EDA and modeling process.
- StoreSalesForecasting_Presentation: A high level presentation about the project & findings.
- streamlit_app: A work-in-progress for deployment of the EDA & forecast results to Streamlit.
Through this project, we can apply Statistical Modeling and Machine Learning for sales forecasting using the SARIMA and Facebook Prophet models for the Favorita stores located in Ecuador. New data time series sales data from this store with similar characteristics can leverage the .joblib models to fit again and forecast the sales.
This project was part of my final capstone project for the Data Science diploma at Lighthouse Labs (Canada), aiming to deliver an end-to-end project.
Process in the main Jupyter Notebook
Output mapping: The store_sales_forecast.ipynb notebook
Output mapping: The store_sales_forecast.ipynb notebook
-
Load the dataset
-
Data Prepping - Converting into Datetime format for all dataframes
-
EDA on 'holidays_df' and 'store_df'
-
Data Prepping and EDA for the main dataframe 'store_sales_df'
-
Decompose the series to see the trend, seasonal, and residual components
-
The augmented Dicky-Fuller test for stationarity
-
Autocorrelation plots (ACF), partial autocorrelation plots (PACF) and Weekly Differencing
-
Train-test split after confirming the data is stationary with D = 1, m = 7
Output mapping: The store_sales_forecast.ipynb notebook, the [sarima_model.joblib] model, the [SARIMA_sales_forecast.xlsx] forecast outputs, the [prophet_model.joblib] model, the [prophet_sales_forecast.xlsx] forecast outputs.
-
SARIMA Model
-
Facebook Prophet Model
-
Compare the RMSE of both Models
Output mapping: The store_sales_forecast.ipynb notebook
-
Prophet is known to handle seasonality and holiday effects well. Our data have a certain degree of effects from the EDA, thus it explains the better performance of Prophet model than the SARIMA model. Given the results, we might favor using the Prophet model or similar models that capture the data patterns of seasonality of grocery sales well. However, if there is new data with different characteristics, the model's performance should be re-evaluated.
-
Business implications: As we mentioned Part 3 of each model, the forecasted sales of SARIMA are mostly higher than the actual sales in our investigated scenarios (totalling sales daily, weekly and monthly). Reversedly, Facebook's Prophet gives a more accurate forecasted sales yet mostly on the lower end compared to actual. Depending on the business strategy of forecasting and performance tracking, we might consider: Using SARIMA's sales forecast results in case of an optimistic business scenario or focusing on setting a high target; whereas using Prophet's sales forecasting for a realistic business scenario or low-target setting.
-
Considerations for Improvement: While Prophet is performing better than SARIMA model, there's still a significant error that we might want to reduce. This could involve hyperparameter tuning, incorporating external variables, or trying different transformations of the data. For now, we're just focusing the time series of the total sales per period.
(Tee) Thanh Nguyen
The dataset was extracted and adapted from kaggle. The code was also developed based on knowledge from: Kaggle, Analyics Vidhya, THI LAN ANH NGUYEN, SATOSHI_S, IRENE A. GYEBI, SHI LONG ZHUANG, TER HUICHEE, FRANCISCO JAVIER GALLEGO, SHRUTI SAXENA, TUSHAR GOEL, MOHAMED EL-SROGY, HOWOO JANG, EKREM BAYAR.