Description Usage Arguments Details Value Methods (by class) See Also Examples
Cross validation for rank and initialization standard deviation with libFM factorization machines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | cv_libFM(x, ...)
## S3 method for class 'data.frame'
cv_libFM(x, formula, validation, grouping,
cv_verbosity = 0, ...)
## S3 method for class 'matrix'
cv_libFM(x, y, validation, y_validation, grouping,
cv_verbosity = 0, ...)
## S3 method for class 'dgCMatrix'
cv_libFM(x, y, validation, y_validation, grouping,
cv_verbosity = 0, ...)
## Default S3 method:
cv_libFM(x, dims = c(0, 8), init_stdevs = 0.1,
folds = 5, validation, grouping, task = c("c", "r"), loss_function,
cv_verbosity = 0, ...)
|
x |
data.frame, (sparse) matrix, or character vector used for cross validation |
... |
arguments passed to libFM |
formula |
formula of response and covariates included |
validation |
validation data.frame, (sparse) matrix, or character vector used for adaptive SGD |
grouping |
logical scalar or integer vector |
cv_verbosity |
how much feedback to give on the progress of cross validation |
y, y_validation |
numeric vectors of responses when train and validation are matrices |
dims |
vector of the two-way interaction dimensions to try |
init_stdevs |
vector of the initialization standard deviations to try |
folds |
number of cross validation folds or integer vector giving the fold ids for each row |
task |
classifcation or regression |
loss_function |
loss function to evaluate. See details for more information |
This function attempts to speed things up by converting all the data to libFM format first, so that there are not repetitive and computationally-costly data conversions.
If unspecified, loss_function
will be mean squared error for regression or
mean Bernoulli deviance for classification. You can specify your own function also.
loss_function
must be a function that takes two vector arguments and returns a scalar numeric.
The first argument is the predicted value / probability and the second is the true value.
A matrix of the cross validated loss_function
. There are length(dims)
rows and length(init_stdevs)
columns.
data.frame
:
matrix
:
dgCMatrix
:
default
:
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## Not run:
data(movie_lens)
mses = cv_libFM(movie_lens, Rating ~ User + Movie,
task = "r", dims = c(0, 5, 10), cv_verbosity = 1)
mses
# with a sparse matrix
movie_mat = Matrix::sparse.model.matrix(Rating ~ User + Movie - 1, movie_lens)
mses = cv_libFM(movie_mat, movie_lens$Rating,
task = "r", dims = c(0, 5, 10), cv_verbosity = 1)
mses
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.