Creates matrix factorization model based on Soft-SVD. Soft SVD is very similar to truncated SVD with ability do add regularization based on nuclear norm.
PureSVD
R6Class
object.
For usage details see Methods, Arguments and Examples sections.
model = PureSVD$new(rank = 10L, lambda = 0, n_threads = parallel::detectCores(), init = NULL, preprocess = identity, ...) model$fit_transform(x, n_iter = 5L, ...) model$predict(x, k, not_recommend = x, ...) model$components
$new(rank = 10L, lambda = 0,
n_threads = parallel::detectCores(),
init = NULL,
preprocess = identity,
...
)
creates matrix
factorization model model with at most rank
latent factors. If init
is not null then initializes
with provided SVD solution
$fit_transform(x, n_iter = 5L, ...)
fits model to
an input user-item matrix.
Returns factor matrix for users of size n_users * rank
$predict(x, k, not_recommend = x, ...)
predict top k
item ids for users x
(= column names from the matrix passed to fit_transform()
method).
Users features should be defined the same way as they were defined in training data - as sparse matrix
of confidence values (implicit feedback) or ratings (explicit feedback).
Column names (=item ids) should be in the same order as in the fit_transform()
.
$components
item factors matrix of size rank * n_items
numeric
default number of threads to use during training and prediction
(if OpenMP is available).
A PureSVD
model.
An input sparse user-item matrix(of class dgCMatrix
)
integer
- maximum number of latent factors
numeric
- regularization parameter for nuclear norm
function
= identity()
by default. User spectified function which will be applied to user-item interaction matrix
before running matrix factorization (also applied in inference time before making predictions). For example we may
want to normalize each row of user-item matrix to have 1 norm. Or apply log1p()
to discount large counts.
numeric
default number of threads to use during training and prediction
(if OpenMP is available).
sparse matrix
or NULL
- points which items should be excluided from recommendations for a user.
By default it excludes previously seen/consumed items.
numeric = -Inf
defines early stopping strategy. We stop fitting
when one of two following conditions will be satisfied: (a) we have used
all iterations, or (b) relative change of frobenious norm of the two consequent solution is less then
provided convergence_tol
other arguments. Not used at the moment