rectools-package: Advanced Recommender System

Description Details Examples

Description

Toolbox for recommender systems, including novel methods, plotting, parallel computation, and so on.

Details

Package: rectools
Type: Package
Version: 1.0.0
Date: 2016-10-29
License: GPL (>= 2)

Raw input data:

Standard form, one row per rating, with first three columns being user ID, item ID and rating, followed by optional covariates. Note: Most functions assume that user and item IDs are numbered consecutively, starting at 1.

List of major functions:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
   matrix factorization model (MFM):

      trainReco():  fit MFM
      predict.Reco():  predict from MFM 
      xvalReco():  cross-validation evaluation of MFM

   statistical random effects additive model:

      findYdotsMLE():  fit Max. Likelihood model
      findYdotsMM():  fit Method of Moments model
      trainMLE():  alias for findYdotsMLE()
      trainMM():  alias for findYdotsMM()
      predict.ydotsMLE():  predict from MLE
      predict.ydotsMM():  predict from MM
      xvalMLE):  cross-validation of MLE
      xvalMM):  cross-validation of MM
      findMultiplicYdots():  fit multiplicative MM model, binary Y

   statistical random effects multiplicative model:

      findYdotsMultiplicYdots(): fit mult. model for binary Y 
      predict.MMmultiplic(): predict from that model 

   k-nearest neighbor model:

      formUserData():  aggregate items for each user, etc.
      cosDist():  calculates cosine distance on users with certain 
         item patterns
      predict.usrData():  predict using kNN

   misc.:

      focusGrp():  finds a "focus group," i.e. some "representative" users
      ratingness():  find number of ratings for each user or 
         number of users per rating
      covratingness():  for each row of the raw input data

   

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# try lme4 data set InstEval, needs some prep first.
data(InstEval)
ivl <- InstEval
# convert factors to numeric:
ivl$s <- as.numeric(ivl$s)
ivl$d <- as.numeric(ivl$d)
ivl$studage <- as.numeric(ivl$studage)
ivl$lectage <- as.numeric(ivl$lectage)
ivl$service <- as.numeric(ivl$service)
# make correct format, and choose covs:
ivl <- ivl[,c(1,2,7,3:6)]
# create dummy variables in place of dept:
library(dummies)
dms <- dummy(ivl$dept)
dms <- as.data.frame(dms)
dms$dept2 <- NULL
ivl$dept <- NULL
ivl <- cbind(ivl,dms)
# run the training data, no covariates:
# ydout <- findYdotsMM(ivl[,1:3])
ydout <- trainMM(ivl[,1:3])
# form a test set to illustrate prediction:
testSet <- ivl[c(3,8),]  # these happen to be students 1, 3
# say want to predict how well students 1 and 3 would like instructor 12
testSet[1,2] <- 12
testSet[2,2] <- 12
# predict:
predict(ydout,testSet[,1:2])  
# try using the covariates:
# ydout <- findYdotsMM(ivl)
ydout <- trainMM(ivl)
predict(ydout,testSet[,-3])  

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