@PublicationReference(title="Factorization Machines",author="Steffen Rendle",year=2010,type=Conference,publication="Proceedings of the 10th IEEE International Conference on Data Mining (ICDM)",url="http://www.inf.uni-konstanz.de/~rendle/pdf/Rendle2010FM.pdf") @PublicationReference(title="Factorization Machines with libFM",author="Steffen Rendle",year=2012,type=Journal,publication="ACM Transactions on Intelligent Systems Technology",url="http://www.csie.ntu.edu.tw/~b97053/paper/Factorization%20Machines%20with%20libFM.pdf") public class FactorizationMachine extends AbstractRegressor<Vector> implements VectorInputEvaluator<Vector,java.lang.Double>, ParameterGradientEvaluator<Vector,java.lang.Double,Vector>
Modifier and Type | Field and Description |
---|---|
protected double |
bias
The bias term (b).
|
protected Matrix |
factors
The k x d factor matrix (v) with k factors for each dimension.
|
protected Vector |
weights
The weight vector (w) for each dimension.
|
Constructor and Description |
---|
FactorizationMachine()
Creates a new, empty
FactorizationMachine . |
FactorizationMachine(double bias,
Vector weights,
Matrix factors)
Creates a new
FactorizationMachine with the given parameters. |
FactorizationMachine(int dimensionality,
int factorCount)
Creates a new, empty
FactorizationMachine of the given
input dimensionality (d) and factor count (k). |
Modifier and Type | Method and Description |
---|---|
FactorizationMachine |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
Vector |
computeParameterGradient(Vector input)
Computes the derivative of the output with respect to the parameters for
a particular input.
|
void |
convertFromVector(Vector parameters)
Converts the object from a Vector of parameters.
|
Vector |
convertToVector()
Converts the object to a vector.
|
double |
evaluateAsDouble(Vector input)
Evaluates the scalar function as a double.
|
double |
getBias()
Gets the bias value.
|
int |
getFactorCount()
Gets the number of factors in the model.
|
Matrix |
getFactors()
Gets the matrix of factors.
|
int |
getInputDimensionality()
Gets the expected dimensionality of the input vector to the evaluator,
if it is known.
|
int |
getParameterCount()
Gets the number of parameters for this factorization machine.
|
Vector |
getWeights()
Gets the weight vector.
|
boolean |
hasFactors()
Determines if this Factorization Machine has pairwise factor terms.
|
boolean |
hasWeights()
Determines if this Factorization Machine has a linear weight term.
|
void |
setBias(double bias)
Sets the bias value.
|
void |
setFactors(Matrix factors)
Sets the matrix of factors.
|
void |
setWeights(Vector weights)
Sets the weight vector.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
evaluate
protected double bias
protected Vector weights
protected Matrix factors
public FactorizationMachine()
FactorizationMachine
. It is initialized
with a bias of zero and no weight or factors.public FactorizationMachine(int dimensionality, int factorCount)
FactorizationMachine
of the given
input dimensionality (d) and factor count (k). It initializes the
internal d-dimensional weight vector and k-by-d factor matrix based on
these sizes. All values are initialized to 0.dimensionality
- The input dimensionality (d). Cannot be negative.factorCount
- The number of factors for pairwise interactions (k). Cannot be
negative.public FactorizationMachine(double bias, Vector weights, Matrix factors)
FactorizationMachine
with the given parameters.bias
- The bias value.weights
- The weight vector of dimensionality d. May be null.factors
- The k-by-d pairwise factor matrix. May be null.public FactorizationMachine clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface Vectorizable
clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public double evaluateAsDouble(Vector input)
ScalarFunction
evaluateAsDouble
in interface ScalarFunction<Vector>
input
- The input value.public int getInputDimensionality()
VectorInputEvaluator
getInputDimensionality
in interface VectorInputEvaluator<Vector,java.lang.Double>
public int getFactorCount()
public Vector computeParameterGradient(Vector input)
ParameterGradientEvaluator
computeParameterGradient
in interface ParameterGradientEvaluator<Vector,java.lang.Double,Vector>
input
- Input about which to compute the parameter gradient.public Vector convertToVector()
Vectorizable
convertToVector
in interface Vectorizable
public void convertFromVector(Vector parameters)
Vectorizable
convertFromVector
in interface Vectorizable
parameters
- The parameters to incorporate.public int getParameterCount()
public boolean hasWeights()
public boolean hasFactors()
public double getBias()
public void setBias(double bias)
bias
- The bias value (b) of the model.public Vector getWeights()
public void setWeights(Vector weights)
weights
- The weight vector. May be null.public Matrix getFactors()
public void setFactors(Matrix factors)
factors
- The matrix of pairwise factors. May be null.