August 2018
Intermediate to advanced
378 pages
9h 9m
English
Before we jump into applying a deep learning model, we should follow the same practice as we have done in previous chapters and create a benchmark accuracy score using a standard machine learning algorithm. It is quick, easy, and will give us confidence that our deep learning model is working better than just using normal machine learning. Here are the 20 lines of code to do collaborative filtering in R. This code can be found in Chapter8/ml_recommend.R:
library(readr)library(recommenderlab)library(reshape2)set.seed(42)in_file <- "../dunnhumby/recommend.csv"df <- read_csv(in_file)dfPivot <-dcast(df, cust_id ~ prod_id)m <- as.matrix(dfPivot[,2:ncol(dfPivot)])recommend <- as(m,"realRatingMatrix")e <- ...