@PublicationReference(title="Fast Context-aware Recommendations with Factorization Machines",author={"Steffen Rendle","Zeno Gantner","Christoph Freudenthaler","Lars Schmidt-Thieme"},year=2011,type=Conference,publication="Proceeding of the 34th international ACM SIGIR conference on Research and development in Information Retrieval (SIGIR)",url="http://www.inf.uni-konstanz.de/~rendle/pdf/Rendle2011-CARS.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",notes="Algorithm 2: Alternating Least Squares (ALS)") public class FactorizationMachineAlternatingLeastSquares extends AbstractFactorizationMachineLearner
FactorizationMachine
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<? extends InputOutputPair<? extends Vector,java.lang.Double>> |
dataList
The data in the form that it can be accessed in O(1) as a list.
|
protected int |
dataSize
The size of the data.
|
static double |
DEFAULT_MIN_CHANGE
The default minimum change is 1.0E-5.
|
protected java.util.ArrayList<Vector> |
inputsTransposed
A list representing a transposed form of the matrix of inputs.
|
protected double |
minChange
The minimum change allowed in an iteration.
|
protected double |
totalChange
The total change from the current iteration.
|
protected double |
totalError
The total error from the current iteration.
|
biasEnabled, biasRegularization, DEFAULT_BIAS_ENABLED, DEFAULT_BIAS_REGULARIZATION, DEFAULT_FACTOR_COUNT, DEFAULT_FACTOR_REGULARIZATION, DEFAULT_MAX_ITERATIONS, DEFAULT_SEED_SCALE, DEFAULT_WEIGHT_REGULARIZATION, DEFAULT_WEIGHTS_ENABLED, dimensionality, factorCount, factorRegularization, random, result, seedScale, weightRegularization, weightsEnabled
data, keepGoing
maxIterations
DEFAULT_ITERATION, iteration
Constructor and Description |
---|
FactorizationMachineAlternatingLeastSquares()
Creates a new
FactorizationMachineAlternatingLeastSquares with
default parameter values. |
FactorizationMachineAlternatingLeastSquares(int factorCount,
double biasRegularization,
double weightRegularization,
double factorRegularization,
double seedScale,
int maxIterations,
double minChange,
java.util.Random random)
Creates a new
FactorizationMachineAlternatingLeastSquares . |
Modifier and Type | Method and Description |
---|---|
protected void |
cleanupAlgorithm()
Called to clean up the learning algorithm's state after learning has
finished.
|
double |
computeObjective()
Gets the total objective, which is the squared error plus the
regularization terms.
|
double |
getMinChange()
Gets the minimum change allowed in an iteration.
|
double |
getObjective()
Gets the total objective, which is the squared error plus the
regularization terms.
|
NamedValue<? extends java.lang.Number> |
getPerformance()
Gets the name-value pair that describes the current performance of the
algorithm.
|
double |
getRegularizationPenalty()
Gets the regularization penalty term in the error for the objective.
|
double |
getTotalChange()
Gets the total change in the model parameters from the current iteration.
|
double |
getTotalError()
Gets the total squared error from the current iteration.
|
protected boolean |
initializeAlgorithm()
Called to initialize the learning algorithm's state based on the
data that is stored in the data field.
|
void |
setMinChange(double minChange)
Sets the minimum change allowed in an iteration.
|
protected boolean |
step()
Called to take a single step of the learning algorithm.
|
getBiasRegularization, getFactorCount, getFactorRegularization, getRandom, getResult, getSeedScale, getWeightRegularization, isBiasEnabled, isFactorsEnabled, isWeightsEnabled, setBiasEnabled, setBiasRegularization, setFactorCount, setFactorRegularization, setRandom, setSeedScale, setWeightRegularization, setWeightsEnabled
clone, getData, getKeepGoing, learn, setData, setKeepGoing, stop
getMaxIterations, isResultValid, setMaxIterations
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
learn
clone
getMaxIterations, setMaxIterations
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
isResultValid
public static final double DEFAULT_MIN_CHANGE
protected double minChange
protected transient int dataSize
protected transient java.util.ArrayList<? extends InputOutputPair<? extends Vector,java.lang.Double>> dataList
protected transient java.util.ArrayList<Vector> inputsTransposed
protected double totalChange
protected double totalError
public FactorizationMachineAlternatingLeastSquares()
FactorizationMachineAlternatingLeastSquares
with
default parameter values.public FactorizationMachineAlternatingLeastSquares(int factorCount, double biasRegularization, double weightRegularization, double factorRegularization, double seedScale, int maxIterations, double minChange, java.util.Random random)
FactorizationMachineAlternatingLeastSquares
.factorCount
- The number of factors to use. Zero means no factors. Cannot be
negative.biasRegularization
- The regularization term for the bias. Cannot be negative.weightRegularization
- The regularization term for the linear weights. Cannot be negative.factorRegularization
- The regularization term for the factor matrix. Cannot be negative.seedScale
- The random initialization scale for the factors.
Multiplied by a random Gaussian to initialize each factor value.
Cannot be negative.maxIterations
- The maximum number of iterations for the algorithm to run. Cannot
be negative.minChange
- The minimum change allowed in an iteration. The algorithm stops if
the change is less than this value. Cannot be negative.random
- The random number generator.protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearner
initializeAlgorithm
in class AbstractFactorizationMachineLearner
protected boolean step()
AbstractAnytimeBatchLearner
step
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends Vector,java.lang.Double>>,FactorizationMachine>
protected void cleanupAlgorithm()
AbstractAnytimeBatchLearner
cleanupAlgorithm
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends Vector,java.lang.Double>>,FactorizationMachine>
public double getTotalChange()
public double getTotalError()
public double getRegularizationPenalty()
public double getObjective()
public double computeObjective()
public NamedValue<? extends java.lang.Number> getPerformance()
MeasurablePerformanceAlgorithm
public double getMinChange()
public void setMinChange(double minChange)
minChange
- The minimum change. Cannot be negative.