trainReco: Recosystem Wrappers

View source: R/trainReco.R

trainReco,predict.RecoS3,trainRecoPar,predict.RecoS3parR Documentation

Recosystem Wrappers

Description

Convenience wrappers for specific aspects of the recosystem package, including adding a parallel computation capability.

Usage

	trainReco(ratingsIn,rnk=10,nmf=FALSE,biasAdjust=FALSE)
	predict.RecoS3(recoObj,testSet)
	trainRecoPar(ratingsIn,rnk=10,nmf=FALSE,cls,pqName='PQ')
	predict.RecoS3par(RecoS3parObj,testSet,cls)

Arguments

ratingsIn

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

rnk

Desired rank for the matrix factors.

nmf

If TRUE, use NMF, otherwise SVD.

biasAdjust

If TRUE, subtract from the input ratings the user "biases," which are the "hat(alpha_i)" in trainMM().

recoObj

Object of class 'RecoS3', output of trainReco.

RecoS3parObj

Object of class 'RecoS3par', output of trainRecoPar.

testSet

Data to be predicted, having within-row format (UserID, ItemID, covariates if any).

Details

The training functions call r$train on the input data. The latter function returns several key components, including the matrices P and Q.

The product PQ' of these two matrices consists of the predicted ratings of all users on all items.

The function predict.RecoS3 is a method for the generic function predict.

Author(s)

Pooja Rajkumar, Norm Matloff and Robin Yancey

Examples

   getInstEval()
   # note: instructor IDs not consecutive
   ivl3 <- ivl[,1:3]
   set.seed(9999)
   trn <- trainReco(ivl3)
   onerec <- ivl3[1,]  # form dummy 1-rec data frame
   # how would student 788 would like lecturer 28?
   onerec$s <- 788  
   onerec$d <- 12  
   onerec <- onerec[,-3]
   predict(trn,onerec)  # 2.46

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