cosine: @title Predict Using k-NN

Description Usage Arguments Value Author(s) Examples

Description

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

Usage

1
  predict.usrData(origData, newData, newItem, k, wtcovs = NULL, wtcats = NULL)

Arguments

origData:

training set, object of class 'usrData', output of findUserData.

newData:

data point (just one for now) to be predicted, object of class usrDatum, same class as each element of the list origData. The userID component can be NA.

newItem:

ID of the item rating to be predicted for the user specified in newData.

k:

number of nearest neighbors.

wtcovs:

weight to put on covariates; NULL if no covs.

wtcats:

weight to put on item categories; NULL if no cats.

Value

Predicted rating for newData.

Author(s)

Vishal Chakraborty and Norm Matloff

Examples

1
2
3
4
5
6
7
     ivl <- InstEval 
     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
     predict(usrdata,usrdata[[3]],8,10)  # 2.6

Pooja-Rajkumar/rectools documentation built on May 8, 2019, 2:56 p.m.