cosine,predict.usrData | R Documentation |
Rating prediction via nearest neighbors, via cosDist
(inner product);
the latter, though standard, has certain problems (e.g., its
scale-free nature), and other choices for distance measure will be added.
covariates (e.g. age, gender) and item type preferences (e.g.
preferred movie genres) are allowed
predict.usrData(origData, newData, newItem, k, wtcovs = NULL, wtcats = NULL)
origData: |
training set, object of class 'usrData', output of
|
newData: |
data point (just one for now) to be predicted, object
of class |
newItem: |
ID of the item rating to be predicted for the user
specified in |
k: |
vector of numbers of nearest neighbors. |
wtcovs: |
weight to put on covariates; NULL if no covs. |
wtcats: |
weight to put on item categories; NULL if no cats. |
Predicted rating for newData
.
Vishal Chakraborty and Norm Matloff
ivl <- InstEval # getInstEval() NOT called ivl$s <- as.numeric(ivl$s) ivl$d <- as.numeric(ivl$d) ivl <- ivl[,c(1,2,7)] usrdata <- formUserData(ivl[,1:3]) # predict the rating user 3 would give item 8; warning, in general # element [[3]] may be have user 3; need code to find user 3 predict(usrdata,usrdata[[3]],8,10) # 2.6 # user not in database nu <- list(userID='88888',itms=c(22,99),ratings=c(5,1)) predict(usrdata,nu,8,10) # 3.2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.