output {recosystem} | R Documentation |
This method is a member function of class "RecoSys
"
that exports the user score matrix P and the item score matrix Q.
Prior to calling this method, model needs to be trained using member function
$train()
.
The common usage of this method is
r = Reco() r$train(...) r$output(out_P = data_file("mat_P.txt"), out_Q = data_file("mat_Q.txt"))
r |
Object returned by |
out_P |
An object of class |
out_Q |
Ditto, but for the item matrix. |
A list with components P
and Q
. They will be filled
with user or item matrix if out_memory()
is used
in the function argument, otherwise NULL
will be returned.
Yixuan Qiu <http://statr.me>
W.-S. Chin, Y. Zhuang, Y.-C. Juan, and C.-J. Lin. A Fast Parallel Stochastic Gradient Method for Matrix Factorization in Shared Memory Systems. ACM TIST, 2015.
W.-S. Chin, Y. Zhuang, Y.-C. Juan, and C.-J. Lin. A Learning-rate Schedule for Stochastic Gradient Methods to Matrix Factorization. PAKDD, 2015.
W.-S. Chin, B.-W. Yuan, M.-Y. Yang, Y. Zhuang, Y.-C. Juan, and C.-J. Lin. LIBMF: A Library for Parallel Matrix Factorization in Shared-memory Systems. Technical report, 2015.
train_set = system.file("dat", "smalltrain.txt", package = "recosystem") r = Reco() set.seed(123) # This is a randomized algorithm r$train(data_file(train_set), opts = list(dim = 10, nmf = TRUE)) ## Write P and Q matrices to files P_file = out_file(tempfile()) Q_file = out_file(tempfile()) r$output(P_file, Q_file) head(read.table(P_file@dest, header = FALSE, sep = " ")) head(read.table(Q_file@dest, header = FALSE, sep = " ")) ## Skip P and only export Q r$output(out_nothing(), Q_file) ## Return P and Q in memory res = r$output(out_memory(), out_memory()) head(res$P) head(res$Q)