| PureSVD {rsparse} | R Documentation |
PureSVD recommender model decompomposition
Description
Creates PureSVD recommender model. Solver is based on Soft-SVD which is very similar to truncated SVD but optionally adds regularization based on nuclear norm.
Super class
rsparse::MatrixFactorizationRecommender -> PureSVD
Methods
Public methods
Inherited methods
Method new()
create PureSVD model
Usage
PureSVD$new(
rank = 10L,
lambda = 0,
init = NULL,
preprocess = identity,
method = c("svd", "impute"),
...
)Arguments
ranksize of the latent dimension
lambdaregularization parameter
initinitialization of item embeddings
preprocessidentity()by default. User spectified function which will be applied to user-item interaction matrix before running matrix factorization (also applied during inference time before making predictions). For example we may want to normalize each row of user-item matrix to have 1 norm. Or applylog1p()to discount large counts.methodtype of the solver for initialization of the orthogonal basis. Original paper uses SVD. See paper for details.
...not used at the moment
Method fit_transform()
performs matrix factorization
Usage
PureSVD$fit_transform(x, n_iter = 100L, convergence_tol = 0.001, ...)
Arguments
xinput sparse user-item matrix(of class
dgCMatrix)n_itermaximum number of iterations
convergence_tolnumeric = -Infdefines early stopping strategy. Stops fitting when one of two following conditions will be satisfied: (a) passed all iterations (b) relative change of Frobenious norm of the two consequent solution is less then providedconvergence_tol....not used at the moment
Method transform()
calculates user embeddings for the new input
Usage
PureSVD$transform(x, ...)
Arguments
xinput matrix
...not used at the moment
Method clone()
The objects of this class are cloneable with this method.
Usage
PureSVD$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
data('movielens100k')
i_train = sample(nrow(movielens100k), 900)
i_test = setdiff(seq_len(nrow(movielens100k)), i_train)
train = movielens100k[i_train, ]
test = movielens100k[i_test, ]
rank = 32
lambda = 0
model = PureSVD$new(rank = rank, lambda = lambda)
user_emb = model$fit_transform(sign(test), n_iter = 100, convergence_tol = 0.00001)
item_emb = model$components
preds = model$predict(sign(test), k = 1500, not_recommend = NULL)
mean(ap_k(preds, actual = test))