Created
May 14, 2016 10:58
-
-
Save klauszhang/95915d49f3c10eb6ad637acae6f6405e to your computer and use it in GitHub Desktop.
iterate through all userid and calculate similarity - not working, consider vectorize.
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
all_user_id <- unique(train$user_id) | |
similar_table<-list() | |
counter<-1 | |
for (user in all_user_id) { | |
similar_user<-c(user) | |
current <- train[user_id == user,] | |
for (next_user in all_user_id[-user]) { | |
# calculate similarity | |
# this is a test | |
if (length(similar_user)==6) { | |
break | |
} | |
append(similar_user, next_user) | |
} | |
similar_table[counter]<-similar_user | |
counter<-counter+1 | |
print(counter) | |
} | |
names(similar_table)<-c('user', 'U1', 'U2', 'U3', 'U4', 'U5') | |
list1 <- list(c(1, 2, 3, 4)) | |
dataframe1 <- data.frame(list1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment