public abstract class AbstractFactorizationMachineLearner extends AbstractAnytimeSupervisedBatchLearner<Vector,java.lang.Double,FactorizationMachine> implements Randomized, MeasurablePerformanceAlgorithm
FactorizationMachine
s. It defines
the common parameters for learning algorithms and how to initialize the
factorization machine for learning.Modifier and Type | Field and Description |
---|---|
protected boolean |
biasEnabled
True if the bias term is enabled.
|
protected double |
biasRegularization
The regularization term for the bias.
|
static boolean |
DEFAULT_BIAS_ENABLED
The default for bias enabled is true.
|
static double |
DEFAULT_BIAS_REGULARIZATION
The default bias regularization parameter is 0.0.
|
static int |
DEFAULT_FACTOR_COUNT
The default number of factors is 10.
|
static double |
DEFAULT_FACTOR_REGULARIZATION
The default factor regularization parameter is 0.01.
|
static int |
DEFAULT_MAX_ITERATIONS
The default maximum number of iterations is 100.
|
static double |
DEFAULT_SEED_SCALE
The default seed initialization scale is 0.01.
|
static double |
DEFAULT_WEIGHT_REGULARIZATION
The default weight regularization parameter is 0.001.
|
static boolean |
DEFAULT_WEIGHTS_ENABLED
The default for weights enabled is true.
|
protected int |
dimensionality
The dimensionality of the input to the factorization machine.
|
protected int |
factorCount
The number of factors to use.
|
protected double |
factorRegularization
The regularization term for the factor matrix.
|
protected java.util.Random |
random
The random number generator to use.
|
protected FactorizationMachine |
result
The current factorization machine output learned by the algorithm.
|
protected double |
seedScale
The standard deviation for initializing the factors.
|
protected double |
weightRegularization
The regularization term for the linear weights.
|
protected boolean |
weightsEnabled
True if the linear weight term is enabled.
|
data, keepGoing
maxIterations
DEFAULT_ITERATION, iteration
Constructor and Description |
---|
AbstractFactorizationMachineLearner()
Creates a new
AbstractFactorizationMachineLearner . |
AbstractFactorizationMachineLearner(int factorCount,
double biasRegularization,
double weightRegularization,
double factorRegularization,
double seedScale,
int maxIterations,
java.util.Random random)
Creates a new
AbstractFactorizationMachineLearner . |
Modifier and Type | Method and Description |
---|---|
double |
getBiasRegularization()
Gets the value for the parameter controlling the bias regularization.
|
int |
getFactorCount()
Gets the number of factors.
|
double |
getFactorRegularization()
Gets the value for the parameter controlling the factor matrix
regularization.
|
java.util.Random |
getRandom()
Gets the random number generator used by this object.
|
FactorizationMachine |
getResult()
Gets the current result of the algorithm.
|
double |
getSeedScale()
Gets the seed initialization scale.
|
double |
getWeightRegularization()
Gets the value for the parameter controlling the linear weight
regularization.
|
protected boolean |
initializeAlgorithm()
Called to initialize the learning algorithm's state based on the
data that is stored in the data field.
|
boolean |
isBiasEnabled()
Gets whether or not the bias term is enabled.
|
boolean |
isFactorsEnabled()
Gets whether or not the factors are enabled.
|
boolean |
isWeightsEnabled()
Gets whether or not the linear weight term is enabled.
|
void |
setBiasEnabled(boolean biasEnabled)
Sets whether or not the bias term is enabled.
|
void |
setBiasRegularization(double biasRegularization)
Sets the value for the parameter controlling the bias regularization.
|
void |
setFactorCount(int factorCount)
Sets the number of factors.
|
void |
setFactorRegularization(double factorRegularization)
Sets the value for the parameter controlling the factor matrix
regularization.
|
void |
setRandom(java.util.Random random)
Sets the random number generator used by this object.
|
void |
setSeedScale(double seedScale)
Sets the seed initialization scale.
|
void |
setWeightRegularization(double weightRegularization)
Sets the value for the parameter controlling the linear weight
regularization.
|
void |
setWeightsEnabled(boolean weightsEnabled)
Sets whether or not the linear weight term is enabled.
|
cleanupAlgorithm, clone, getData, getKeepGoing, learn, setData, setKeepGoing, step, stop
getMaxIterations, isResultValid, setMaxIterations
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPerformance
learn
clone
getMaxIterations, setMaxIterations
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
isResultValid
public static final int DEFAULT_FACTOR_COUNT
public static final boolean DEFAULT_BIAS_ENABLED
public static final boolean DEFAULT_WEIGHTS_ENABLED
public static final double DEFAULT_BIAS_REGULARIZATION
public static final double DEFAULT_WEIGHT_REGULARIZATION
public static final double DEFAULT_FACTOR_REGULARIZATION
public static final double DEFAULT_SEED_SCALE
public static final int DEFAULT_MAX_ITERATIONS
protected boolean biasEnabled
protected boolean weightsEnabled
protected int factorCount
protected double biasRegularization
protected double weightRegularization
protected double factorRegularization
protected double seedScale
protected java.util.Random random
protected transient FactorizationMachine result
protected transient int dimensionality
public AbstractFactorizationMachineLearner()
AbstractFactorizationMachineLearner
.public AbstractFactorizationMachineLearner(int factorCount, double biasRegularization, double weightRegularization, double factorRegularization, double seedScale, int maxIterations, java.util.Random random)
AbstractFactorizationMachineLearner
.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.random
- The random number generator.protected boolean initializeAlgorithm()
AbstractAnytimeBatchLearner
initializeAlgorithm
in class AbstractAnytimeBatchLearner<java.util.Collection<? extends InputOutputPair<? extends Vector,java.lang.Double>>,FactorizationMachine>
public FactorizationMachine getResult()
AnytimeAlgorithm
getResult
in interface AnytimeAlgorithm<FactorizationMachine>
public int getFactorCount()
public void setFactorCount(int factorCount)
factorCount
- The number of factors to use. Zero means no factors. Cannot be
negative.public boolean isBiasEnabled()
public void setBiasEnabled(boolean biasEnabled)
biasEnabled
- True if the bias term is enabled, otherwise false.public boolean isWeightsEnabled()
public void setWeightsEnabled(boolean weightsEnabled)
weightsEnabled
- True if the linear term is enabled, otherwise false.public boolean isFactorsEnabled()
public double getBiasRegularization()
public void setBiasRegularization(double biasRegularization)
biasRegularization
- The regularization term for the bias. Cannot be negative.public double getWeightRegularization()
public void setWeightRegularization(double weightRegularization)
weightRegularization
- The regularization term for the weights. Cannot be negative.public double getFactorRegularization()
public void setFactorRegularization(double factorRegularization)
factorRegularization
- The regularization term for the factors. Cannot be negative.public double getSeedScale()
public void setSeedScale(double seedScale)
seedScale
- The random initialization scale for the factors. Cannot be negative.public java.util.Random getRandom()
Randomized
getRandom
in interface Randomized
public void setRandom(java.util.Random random)
Randomized
setRandom
in interface Randomized
random
- The random number generator for this object to use.