| FactorizationMachine | R Documentation |
Creates second order Factorization Machines model
new()creates Creates second order Factorization Machines model
FactorizationMachine$new(
learning_rate_w = 0.2,
rank = 4,
lambda_w = 0,
lambda_v = 0,
family = c("binomial", "gaussian"),
intercept = TRUE,
learning_rate_v = learning_rate_w
)learning_rate_wlearning rate for features intercations
rankdimension of the latent dimensions which models features interactions
lambda_wregularization for features interactions
lambda_vregularization for features
familyone of "binomial", "gaussian"
interceptlogical, indicates whether or not include intecept to the model
learning_rate_vlearning rate for features
partial_fit()fits/updates model
FactorizationMachine$partial_fit(x, y, weights = rep(1, length(y)), ...)
xinput sparse matrix. Native format is Matrix::RsparseMatrix.
If x is in different format, model will try to convert it to RsparseMatrix
with as(x, "RsparseMatrix"). Dimensions should be (n_samples, n_features)
yvector of targets
weightsnumeric vector of length 'n_samples'. Defines how to amplify SGD updates for each sample. May be useful for highly unbalanced problems.
...not used at the moment
fit()shorthand for applying 'partial_fit' 'n_iter' times
FactorizationMachine$fit(x, y, weights = rep(1, length(y)), n_iter = 1L, ...)
xinput sparse matrix. Native format is Matrix::RsparseMatrix.
If x is in different format, model will try to convert it to RsparseMatrix
with as(x, "RsparseMatrix"). Dimensions should be (n_samples, n_features)
yvector of targets
weightsnumeric vector of length 'n_samples'. Defines how to amplify SGD updates for each sample. May be useful for highly unbalanced problems.
n_iternumber of SGD epochs
...not used at the moment
predict()makes predictions based on fitted model
FactorizationMachine$predict(x, ...)
xinput sparse matrix of shape (n_samples, n_featires)
...not used at the moment
clone()The objects of this class are cloneable with this method.
FactorizationMachine$clone(deep = FALSE)
deepWhether to make a deep clone.
# Factorization Machines can fit XOR function!
x = rbind(
c(0, 0),
c(0, 1),
c(1, 0),
c(1, 1)
)
y = c(0, 1, 1, 0)
x = as(x, "RsparseMatrix")
fm = FactorizationMachine$new(learning_rate_w = 10, rank = 2, lambda_w = 0,
lambda_v = 0, family = 'binomial', intercept = TRUE)
res = fm$fit(x, y, n_iter = 100)
preds = fm$predict(x)
all(preds[c(1, 4)] < 0.01)
all(preds[c(2, 3)] > 0.99)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.