You are on page 1of 10

TASK #1: UNDERSTAND THE PROBLEM STATEMENT AND

BUSINESS CASE

Figure 1. Future Sales Time-series Prediction


TASK #2: IMPORT LIBRARIES AND DATASET

# You will need to mount your drive using the following commands:
# For more information regarding mounting, please check this out: https://stackoverflow.co

TASK #2.1: IMPORT SALES TRAINING DATA

# You have to include the full link to the csv file containing your dataset

sales_train_df.head(5)
# almost a million observation 
# 1115 unique stores 
# Note that sales is the target variable (that's what we are trying to predict) 

# Id: transaction ID (combination of Store and date) 
# Store: unique store Id
# Sales: sales/day, this is the target variable 
# Customers: number of customers on a given day
# Open: Boolean to say whether a store is open or closed (0 = closed, 1 = open)
# Promo: describes if store is running a promo on that day or not
# StateHoliday: indicate which state holiday (a = public holiday, b = Easter holiday, c = 
# SchoolHoliday: indicates if the (Store Date) was affected by the closure of public scho
# SchoolHoliday: indicates if the (Store, Date) was affected by the closure of public scho
# Data Source: https://www.kaggle.com/c/rossmann-store-sales/data

# 9 columns in total 
# 8 features, each contains 1017209 data points
# 1 target variable (sales)

# Average sales amount per day = 5773 Euros, minimum sales per day = 0, maximum sales per 
# Average number of customers = 633, minimum number of customers = 0, maximum number of cu

TASK #2.2: IMPORT STORE INFORMATION DATA

# StoreType: categorical variable to indicate type of store (a, b, c, d)
# Assortment: describes an assortment level: a = basic, b = extra, c = extended
# CompetitionDistance (meters): distance to closest competitor store
# CompetitionOpenSince [Month/Year]: provides an estimate of the date when competition was 
# Promo2: Promo2 is a continuing and consecutive promotion for some stores (0 = store is n
# Promo2Since [Year/Week]: date when the store started participating in Promo2
# PromoInterval: describes the consecutive intervals Promo2 is started, naming the months 

# Let's do the same for the store_info_df data
# Note that the previous dataframe includes the transactions recorded per day (in millions
# This dataframe only includes information about the unique 1115 stores that are part of t

# on average, the competition distance is 5404 meters away (5.4 kms)

TASK #3: EXPLORE DATASET

TASK #3.1: EXPLORE SALES TRAINING DATA

# Let's see if we have any missing data, luckily we don't!
# Average 600 customers per day, maximum is 4500 (note that we can't see the outlier at 73
# Data is equally distibuted across various Days of the week (~150000 observations x 7 day 
# Stores are open ~80% of the time
# Data is equally distributed among all stores (no bias)
# Promo #1 was running ~40% of the time 
# Average sales around 5000-6000 Euros
# School holidays are around ~18% of the time

# Let's see how many stores are open and closed! 

# Count the number of stores that are open and closed

# only keep open stores and remove closed stores

# Let's drop the open column since it has no meaning now

# Average sales = 6955 Euros, average number of customers = 762 (went up)

TASK #3.2: EXPLORE STORES INFORMATION DATA

# Let's see if we have any missing data in the store information dataframe!

# Let's take a look at the missing values in the 'CompetitionDistance'
# Only 3 rows are missing 

# Let's take a look at the missing values in the 'CompetitionOpenSinceMonth'
# many rows are missing = 354 (almost one third of the 1115 stores)
# It seems like if 'promo2' is zero, 'promo2SinceWeek', 'Promo2SinceYear', and 'PromoInter
# There are 354 rows where 'CompetitionOpenSinceYear' and 'CompetitionOpenSinceMonth' is m
# Let's set these values to zeros 

# There are 3 rows with 'competitionDistance' values missing, let's fill them up with with 

# half of stores are involved in promo 2
# half of the stores have their competition at a distance of 0-3000m (3 kms away)

TASK #3.3: EXPLORE MERGED DATASET

# Let's merge both data frames together based on 'store'

# customers and promo are positively correlated with the sales 
# Promo2 does not seem to be effective at all 

# Customers/Prmo2 and sales are strongly correlated 

# Let's separate the year and put it into a separate column 

# Let's do the same for the Day and Month

# Let's take a look at the average sales and number of customers per month 
# 'groupby' works great by grouping all the data that share the same month column, then ob
# It looks like sales and number of customers peak around christmas timeframe
# Let's take a look at the sales and customers per day of the month instead
# Minimum number of customers are generally around the 24th of the month 
# Most customers and sales are around 30th and 1st of the month

# Let's do the same for the day of the week  (note that 7 = Sunday)

TASK #4: UNDERSTAND THE INTUITION BEHIND


FACEBOOK PROPHET
TASK #5: TRAIN THE MODEL PART A

# import prophet 
TASK #6: TRAIN THE MODEL PART B

StateHoliday: indicates a state holiday. Normally all stores, with few exceptions, are closed
on state holidays. Note that all schools are closed on public holidays and weekends. a =
public holiday, b = Easter holiday, c = Christmas, 0 = None
SchoolHoliday: indicates if the (Store, Date) was affected by the closure of public schools

# Get all the dates pertaining to school holidays 

# Get all the dates pertaining to state holidays 

# concatenate both school and state holidays 

# Let's make predictions using holidays for a specific store

EXCELLENT JOB!

You might also like