predict {recosystem} | R Documentation |
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 using member function
$train()
.
The common usage of this method is
r = Reco() r$train(...) r$predict(test_data, out_pred = data_file("predict.txt")
r |
Object returned by |
train_data |
An object of class "DataSource" that describes the source
of testing data, typically returned by function
|
out_pred |
An object of class |
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()
## Not run: train_file = data_file(system.file("dat", "smalltrain.txt", package = "recosystem")) test_file = data_file(system.file("dat", "smalltest.txt", package = "recosystem")) r = Reco() set.seed(123) # This is a randomized algorithm opts_tune = r$tune(train_file)$min r$train(train_file, opts = opts_tune) ## Write predicted values into file out_pred = out_file(tempfile()) r$predict(test_file, out_pred) ## Return predicted values in memory pred = r$predict(test_file, out_memory()) ## If testing data are stored in memory test_df = read.table(test_file@source, sep = " ", header = FALSE) pred2 = r$predict(data_memory(test_df[, 1], test_df[, 2]), out_memory()) ## Compare results print(scan(out_pred@dest, n = 10)) head(pred, 10) head(pred2, 10) ## End(Not run)