Learn R Programming

recosystem (version 0.2.5)

output: Output Factorization Matrices

Description

This method is a member function of class "RecoSys" that could write the user score matrix $P$ and item score matrix $Q$ to text files.

Prior to calling this method, model needs to be trained by calling $train().

The common usage of this method is r = Reco() r$output(out_P = file.path(tempdir(), "mat_P.txt"), out_Q = file.path(tempdir(), "mat_Q.txt"))

Arguments

r
Object returned by Reco()
out_P
Filename of the output user score matrix. Note that this contains the transpose of the $P$ matrix, hence each row in the file stands for a user, and each column stands for a latent factor. Values are space seperated.
out_Q
Filename of the output item score matrix. Note that this contains the transpose of the $Q$ matrix, hence each row in the file stands for an item, and each column stands for a latent factor. Values ar

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, predict

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 = 10))
P = tempfile()
Q = tempfile()
r$output(P, Q)

## Inspect these two matrices
head(read.table(P, header = FALSE, sep = ""))
head(read.table(Q, header = FALSE, sep = ""))

Run the code above in your browser using DataLab