cosine: @title Predict Using k-NN

cosine,predict.usrDataR Documentation

@title Predict Using k-NN

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

  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:

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.

Value

Predicted rating for newData.

Author(s)

Vishal Chakraborty and Norm Matloff

Examples

     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

matloff/rectools documentation built on March 31, 2022, 12:09 p.m.