I'm constrained to use a perceptron based method. I have a user-item matrix filled with rating data on scale of 1 to 5 like this, with around 50% of the matrix with no data:

r<- matrix(c(2,4, NA,5,NA,3, NA,5,NA,1,NA,3,NA,5,NA,4,4,NA,NA,NA,1,1,2,NA,1,1,1,1,NA,NA,NA,NA,2,3,4,2,NA,NA,NA,NA,3,4,5,1,NA,NA,2,3,NA), nrow=7).
#one row represents one user, hile one column represents one item
    [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]    2    5   NA    1   NA    2    5
[2,]    4   NA    4    2   NA   NA    1
[3,]   NA    1    4   NA   NA   NA   NA
[4,]    5   NA   NA    1   NA   NA   NA
[5,]   NA    3   NA    1    2   NA    2
[6,]    3   NA   NA    1    3    3    3
[7,]   NA    5    1    1    4    4   NA

I'm recoding the NA's to 0's, which makes the perceptron give out only 2 classes (one containing all the 1's and 0's , and the other containing all the 2,3,4 and 5. Which is understandable I guess.) How do I deal with this? I tried mean imputation but the results are not good (20% accuracy)

(I can't give exact code due to this being a proprietary code of my company, but any perceptron based method should work for this example)

  • $\begingroup$ Is 3 considered as neutral? if yes, it makes more sense to replace with 3 rather than 0. This might not be the perfect approach, but try checking it makes any difference. The reason is, if you replace with 0 then he disliked the movie which might mislead, instead you can try understanding what happens when you replace with 3. $\endgroup$
    – Toros91
    Mar 22, 2018 at 1:28
  • $\begingroup$ another procedure is to predict the missing values based on the available data, there is a paper published on that. Please go through the Link. $\endgroup$
    – Toros91
    Mar 22, 2018 at 1:30

1 Answer 1


Recoding the NAs to 0's is not what you want. Think of what this means: a missing value on an item for a particular user means that said user hasn't seen or listened to or bought (depending on what kind of data you have) that item, while a zero value means that the user disliked that item; so they have completely different meanings.

The goal of a recommender system is basically to fill those NA values in a way that "makes sense". It is very common to have sparse matrices in recommender systems. I don't know exactly what kind of approach you're using or why you're using a perceptron, but I would recommend you to check how matrix factorization for recommender systems works ("Matrix factorization for recommender systems" by Robert Bell, Chris Volinsky and Yehuda Koren is a good paper) and see if this approach works for your problem.

You can also try first a simple baseline model that takes into account the biases of the users and the biases of the items; Bell, Volinsky and Koren's paper is a good start.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.