Learn R Programming

recosystem (version 0.2.4)

predict: Recommender model predictions

Description

This method is a member function of class "RecoSys" that predicts unknown entries in the rating matrix. Prior to calling this method, model needs to be trained by calling $train(), and testing data also must be set through $convert_test(). Prediction results will be written into the specified file, one value per line, corresponding to the testing data.

The common usage of this method is r = Reco() r$predict(outfile, verbose = TRUE)

Arguments

r
Object returned by Reco()
outfile
Name of the output file for prediction
verbose
Whether to show detailed information. Default is TRUE.

References

LIBMF: A Matrix-factorization Library for Recommender Systems. http://www.csie.ntu.edu.tw/~cjlin/libmf/

Y. Zhuang, W.-S. Chin, Y.-C. Juan, and C.-J. Lin. A Fast Parallel Stochastic Gradient Method for Matrix Factorization in Shared Memory Systems. Technical report 2014.

See Also

convert, train

Examples

Run this code
set.seed(123) # this is a randomized algorithm
trainset = system.file("dat", "smalltrain.txt", package = "recosystem")
testset = system.file("dat", "smalltest.txt", package = "recosystem")
r = Reco()
r$convert_train(trainset)
r$convert_test(testset)
r$train(opts = list(dim = 100, niter = 100,
                    cost.p = 0.001, cost.q = 0.001))
outfile = tempfile()
r$predict(outfile)

## Compare the first few true values of testing data
## with predicted ones
print(read.table(testset, header = FALSE, sep = "", nrows = 10)$V3)
print(scan(outfile, n = 10))

Run the code above in your browser using DataLab