Last active
June 21, 2019 17:42
-
-
Save Harshit1694/2e1608296d11b730d2e101a722454c7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(recommenderlab) | |
#Convert data.frame in to transactions: | |
#Convert to binaryRatingMatrix: | |
data_train <- as(data_train, "transactions") | |
data_train_1 <- as(data_train, "binaryRatingMatrix") | |
data_test<- as(data_test, "transactions") | |
data_test_1 <- as(data_test, "binaryRatingMatrix") | |
# Find top 10 recomm movies with Item based collab filter | |
model1 <- Recommender(data = movies3, method = "IBCF", parameter = list(k = 25, | |
method = "pearson")) | |
model1 | |
# Applying model to test | |
predicted1 <- predict(object = model1, newdata = data_test_1, n = 10) | |
predicted1 | |
# The latest among those predicted for each user as most recommended | |
reccom <- data.frame(user_id= sort(rep(1:length(predicted1@items))), | |
rating = unlist(predicted1@ratings), movie_id = unlist(predicted1@items)) | |
#Displaying the recommendations for first 25 users | |
reccom_list<- reccom[order(reccom$user_id),] | |
head(reccom_list,25) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment