cosDist: Cosine-Based Analysis

Description Usage Arguments Details Author(s) Examples

Description

Similarity-based analysis via inner products of user ratings, and possibly other variables. EXPERIMENTAL for now.

Usage

1
2
3
formUserData(ratingsIn, usrCovs = NULL, itmCats = NULL, fileOut = "") 
cosDist(x, y, wtcovs, wtcats)
predict.usrData(origData, newData, newItem, k, wtcovs = NULL, wtcats = NULL)

Arguments

ratingsIn

Input data frame, training set. Within-row format is (UserID, ItemID, rating).

usrCovs

Data frame of user covariates, e.g. gender and age, one row per user.

itmCats

Data frame of item categories, e.g. gender and age, one row per user.

x

Object of class usrDatum.

y

Object of class usrDatum.

wtcovs

Weight to be placed on covariates, relative to ratings variables.

wtcats

Weight to be placed on categories, relative to ratings variables.

origData

Object of class 'usrData', serving as the training set.

newData

Object of class 'usrDatum', to be predicted.

newItem

The item ID of the rating to be predicted.

k

Number of nearest neighbors.

fileOut

A file name.

Details

The function formUserData inputs the usual (user ID,item ID,rating) data, and outputs an R list, of class usrData that has one element per user ID. That element, of class usrDatum, has the following components:

In cosDist, the "distance" (not actually a metric) between numeric vectors u and v is defined to be (u,v) / sqrt((u,u) (v,v)), where ( , ) means inner product. The function cosDist finds this for two objects of class 'usrDatum', with the inner product being taken on the ratings contained in each of these objects, as well as the covariates and category data if any.

The function predict.usrData uses a training set, of class usrData, to predict one new data point, of class usrDatum.

Author(s)

Norm Matloff and Vishal Chakraborty

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
ivl <- InstEval 
ivl$s <- as.numeric(ivl$s) 
ivl$d <- as.numeric(ivl$d) 
ivl <- ivl[,c(1,2,7)] 
ivl10 <- ivl[1:10,] 
ivl10ud <- formUserData(ivl10)
ivl10ud[[1]]
# output of last is
# $userID  
# [1] 1  
#   
# $itms  
# [1]  525  560  832 1068  
#   
# $ratings  
# [1] 5 2 5 3  
#   
# attr(,"class")  
# [1] "usrDatum"  

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