Description Usage Arguments Details Author(s) Examples
Similarity-based analysis via inner products of user ratings, and possibly other variables. EXPERIMENTAL for now.
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)
|
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 |
y |
Object of class |
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 |
newData |
Object of class |
newItem |
The item ID of the rating to be predicted. |
k |
Number of nearest neighbors. |
fileOut |
A file name. |
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:
userID:
User ID.
itms:
Vector of IDs for items rated by this user.
ratings:
Vector of ratings for those items.
usrCovs:
Vector of values of covariates, e.g. gender and
age, for this user.
itmCats:
Vector of proportions for the item categories
(need not sum to 1) for this user. The j-th one is the proportion
of items rating by this user in item category j.
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
.
Norm Matloff and Vishal Chakraborty
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"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.