Training
Basic training requires a sparse matrix of feature vectors as columns per data point X
and a corresponding label vector y
.
using FactorizationMachines
T = [
5 1 0 1 0 0 0 1 0 0 12.5;
5 1 0 0 1 0 0 1 0 0 20;
4 1 0 0 0 1 0 1 0 0 78;
1 0 1 1 0 0 0 0 0 1 12.5;
1 0 1 0 1 0 0 0 0 1 20;
]
X = sparse(T[:,2:end])'
y = T[:,1]
fm = train(X, y)
The training procedure has several components that are specified as keyword arguments to the training procedure: method
, evaluator
, model_params
, and task_params
. All instances of a component are specified within their corresponding submodule: Methods
, Evaluators
, Models
, and Tasks
. Each component has a default. If no components have explicit instances specified, the base training procedure train(X, y)
is equivalent to the following specification of component instances.
fm = train(X, y,
method = Methods.sgd(alpha = 0.01, num_epochs = UInt(100), reg0 = .0, regv = .0, regw = .0),
evaluator = Evaluators.rmse(),
task_params = Tasks.regression(),
model_params = Models.gauss(k0 = true, k1 = true, num_factors = 8, mean = .0, stddev = .01)
The Methods
module contains a single method for learning:
-
Methods.sgd
for stochastic gradient descent
fm = train(X, y, method = Methods.sgd(alpha = 0.01, num_epochs = 100)
The Evaluators
module contains two evaluation types:
-
Evaluators.rmse
for using RMSE in evaluations -
Evaluators.heaviside
for using the heaviside function for evaluations
The Tasks
module contains two types of tasks:
-
Tasks.regression
specifies a regression task -
Tasks.classification
specifies a classification task
The Models
module contains a single instance for model initialization:
-
Models.gauss
initializes from a multivariate normal distribution