demand_classification.Rmd
library(m5)
library(zeallot)
library(ggplot2)
m5_download('data')
c(sales_train,
sales_test,
sell_prices,
calendar,
weights) %<-% m5_get_raw_evaluation('data')
m5_data <-
m5_prepare(sales_train, sales_test, calendar, sell_prices)
head(m5_data)
#> item_id dept_id cat_id store_id state_id d value wm_yr_wk weekday
#> 1: HOBBIES_1_001 HOBBIES_1 HOBBIES CA_1 CA 1 0 11101 Saturday
#> 2: HOBBIES_1_002 HOBBIES_1 HOBBIES CA_1 CA 1 0 11101 Saturday
#> 3: HOBBIES_1_003 HOBBIES_1 HOBBIES CA_1 CA 1 0 11101 Saturday
#> 4: HOBBIES_1_004 HOBBIES_1 HOBBIES CA_1 CA 1 0 11101 Saturday
#> 5: HOBBIES_1_005 HOBBIES_1 HOBBIES CA_1 CA 1 0 11101 Saturday
#> 6: HOBBIES_1_006 HOBBIES_1 HOBBIES CA_1 CA 1 0 11101 Saturday
#> wday month year event_name_1 event_type_1 event_name_2 event_type_2 snap
#> 1: 1 1 2011 <NA> <NA> <NA> <NA> 0
#> 2: 1 1 2011 <NA> <NA> <NA> <NA> 0
#> 3: 1 1 2011 <NA> <NA> <NA> <NA> 0
#> 4: 1 1 2011 <NA> <NA> <NA> <NA> 0
#> 5: 1 1 2011 <NA> <NA> <NA> <NA> 0
#> 6: 1 1 2011 <NA> <NA> <NA> <NA> 0
#> sell_price
#> 1: NA
#> 2: NA
#> 3: NA
#> 4: NA
#> 5: NA
#> 6: NA
m5_demand <- m5_demand_type(m5_data)
foods_demand <-
m5_demand[startsWith(as.character(m5_demand$item_id), "FOODS_1")]
plot <-
ggplot(foods_demand) +
geom_point(aes(log(cv2), log(adi),
item_id = item_id, col = demand_type)) +
geom_hline(yintercept = log(1.32)) +
geom_vline(xintercept = log(0.49)) +
theme_minimal()
plot