Walmart-recruiting-store-sales-forecasting
By: Aljawharah Aldukhayni
Tags: Data Visualization, Data Science, Tableau, Data, Machine Learning

PROJECT OVERVIEW

In this post, I will guide you through building some regressor from the scikit-learn library then , we will highlight the best accuracy.

PROBLEM STATEMENT

One of the leading retail stores in the US, Walmart, would like to predict the sales and demand accurately. There are certain events and holidays which impact sales on each day. There are sales data available for 45 stores of Walmart. The business is facing a challenge due to unforeseen demands and runs out of stock some times, due to the inappropriate machine learning algorithm. An ideal ML algorithm will predict demand accurately and ingest factors like economic conditions including CPI, Unemployment Index, etc.

METRICS

I used cross_val_score from sklearn.model_selection library to check the accuracy of the models .

DATA EXPLORATION

This is the historical data that covers sales from 2010–02–05 to 2012–11–01, in the file Walmart_Store_sales. Within this file you will find the following fields:

Store — the store number

Date — the week of sales

Weekly_Sales — sales for the given store

Holiday_Flag — whether the week is a special holiday week 1 — Holiday week 0 — Non-holiday week

Temperature — Temperature on the day of sale

Fuel_Price — Cost of fuel in the region

CPI — Prevailing consumer price index

Unemployment — Prevailing unemployment rate

Holiday Events

Super Bowl: 12-Feb-10, 11-Feb-11, 10-Feb-12, 8-Feb-13

Labor Day: 10-Sep-10, 9-Sep-11, 7-Sep-12, 6-Sep-13

Thanksgiving: 26-Nov-10, 25-Nov-11, 23-Nov-12, 29-Nov-13

Christmas: 31-Dec-10, 30-Dec-11, 28-Dec-12, 27-Dec-13

Download Dataset here

Through this post we will try to solve these important questions :

1- Are sales effected by changing Store ?

2- Are sales effected by changing Store type ?

3- Are sales effected by changing Store size ?

4- Are sales effected by holidays ?

Finally, predict weekly sales for each store/dep.

VISUALIZATION

1- Are sales effected by changing Store ?

Just as an observation , the mean are very different , whish make me think some stores/ departments might sell such more than others.

2- Are sales effected by changing Store type ?

As an observation , I can say that weekly sales change depends on store size.

3- Are sales effected by changing Store size ?

As an observation , I can say that each there is a direct relationship between store size and weekly sales.

4- Are sales effected by holidays ?

As above we can say that ,weekly sales increase in holidays.

DATA PREPROCESSING STEPS

Missing values and working with categorical variables introduced some complications for fitting machine learning models with sklearn.

So first of all , We will check the missing values and variables data types.

There are missing values and I impute them like above.

change type to be numeric values .

IMPLEMENTATION

I build multiple models ( LinearRegression , DecisionTreeRegressor , RandomForestRegressor and KNeighborsRegressor ) by sklearn library.

RESULTS

The best accuracy I got : RandomForestRegressor which has a training score of 97.0 % accuracy score.

JUSTIFICATION

At the end I can forecast the weekly sales for 99 departments at 45 Walmart stores located in different regions.

GITHUB CODE

To access the code for this post please click here.

TABLEAU DASHBOARD

To access the dashboard please click here.

FUTURE IMPROVEMENTS

This was session of simple data exploration, plotting and building regressor,

I wish to create more advance in the near future.

If any errors are found, please email me at aljawharah.aldukhayni@gmail.com