Recommendation engines

machine_learning

#1

Hi All,

stuck with the following in Hands on Recommendation engines.

#Get the list of merchants/items

merchant <- unique(input$individual_merchant)
merchant <- merchant[order(merchant)]
target_merchants <- merchant
sno <- 1:length(target_merchants)
merchant_ident <- cbind(target_merchants,sno)

#Create a reference mapper for all merchant

colnames(merchant_ident) <- c(“individual_merchant”,“sno”)

Create a correlation matrix for these merchants

correlation_mat = matrix(0,length(merchant),length(target_merchants))
correlation_mat = as.data.frame(correlation_mat)

trans = read.transactions(“C:/Users/Apricot/Downloads/data.csv”
, format = “single”, sep = “,”, cols = c(“inidividual_customer”, “individual_merchant”))

c <- crossTable(trans)
rowitem <- rownames©
columnitem <- colnames©

correlation_mat <- c[order(as.numeric(rowitem)),order(as.numeric(columnitem))]
for(i in 1:9822) { correlation_mat[i,] <- correlation_mat[i,]/correlation_mat[i,i]}

when I run the abovecode am stuck with the following error
Error in correlation_mat[i, ] : subscript out of bounds

Regards,
Tony