calhoun.analysis.crf.solver
Class StandardOptimizer

java.lang.Object
  extended by calhoun.analysis.crf.solver.StandardOptimizer
All Implemented Interfaces:
CRFTraining

public class StandardOptimizer
extends java.lang.Object
implements CRFTraining

uses a L-BFGS algorithm to optimize the objective function. This is the algorithm normally used. Several configuration parameters all you to control optimization parameters:

This optimizer requires one property to be set:

gradFunc - This is the gradient function that the optimizer will use. It must be a reference to a bean that implements the CRFObjectiveFunctionGradient interface.

In addition, it has several optional properties that allow control over the optimization process:


Constructor Summary
StandardOptimizer()
           
 
Method Summary
 int getDebugLevel()
           
 double getEpsForConvergence()
           
 int getMaxIters()
           
 int getMForHessian()
           
 CRFObjectiveFunctionGradient getObjectiveFunction()
          returns the configured objective function gradient which will be used by the optimizer during the training process.
 double getQuadraticRegularization()
           
 double[] getStarts()
           
 int getUnchangedObjective()
           
 boolean isFixFirstWeight()
           
 boolean isRequireConvergence()
           
 double[] optimize(ModelManager fm, java.util.List<? extends TrainingSequence<?>> data)
          find the set of weights which maximizes the value of the objective function.
 void setDebugLevel(int debugLevel)
           
 void setEpsForConvergence(double epsForConvergence)
           
 void setFixFirstWeight(boolean fixFirstWeight)
           
 void setMaxIters(int maxIters)
           
 void setMForHessian(int forHessian)
           
 void setObjectiveFunction(CRFObjectiveFunctionGradient objectiveFunction)
          sets the objective function gradient.
 void setQuadraticRegularization(double quadraticRegularization)
           
 void setRequireConvergence(boolean requireConvergence)
           
 void setStarts(double[] starts)
          Sets the starting weights for the optimization.
 void setUnchangedObjective(int unchangedObjective)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardOptimizer

public StandardOptimizer()
Method Detail

optimize

public double[] optimize(ModelManager fm,
                         java.util.List<? extends TrainingSequence<?>> data)
Description copied from interface: CRFTraining
find the set of weights which maximizes the value of the objective function. The CRFObjectiveFunctionGradient object will already be configured witht eh appropriate training data, so it appears here as a pure function evaluation.

Specified by:
optimize in interface CRFTraining
Parameters:
fm - the model to train on.
data - the training data to use for training.
Returns:
an array of doubles containing the optimal weights.

getObjectiveFunction

public CRFObjectiveFunctionGradient getObjectiveFunction()
returns the configured objective function gradient which will be used by the optimizer during the training process.

Returns:
the configured objective function gradient

setObjectiveFunction

public void setObjectiveFunction(CRFObjectiveFunctionGradient objectiveFunction)
sets the objective function gradient. Called automatically during configuration.


getDebugLevel

public int getDebugLevel()

setDebugLevel

public void setDebugLevel(int debugLevel)

getEpsForConvergence

public double getEpsForConvergence()

setEpsForConvergence

public void setEpsForConvergence(double epsForConvergence)

isFixFirstWeight

public boolean isFixFirstWeight()

setFixFirstWeight

public void setFixFirstWeight(boolean fixFirstWeight)

getMaxIters

public int getMaxIters()

setMaxIters

public void setMaxIters(int maxIters)

getMForHessian

public int getMForHessian()

setMForHessian

public void setMForHessian(int forHessian)

getQuadraticRegularization

public double getQuadraticRegularization()

setQuadraticRegularization

public void setQuadraticRegularization(double quadraticRegularization)

isRequireConvergence

public boolean isRequireConvergence()

setRequireConvergence

public void setRequireConvergence(boolean requireConvergence)

getStarts

public double[] getStarts()

setStarts

public void setStarts(double[] starts)
Description copied from interface: CRFTraining
Sets the starting weights for the optimization.

Specified by:
setStarts in interface CRFTraining
Parameters:
starts - an array of weights to use as the starting point for the optimizer. The optimzier is not required to use this as a starting point.

getUnchangedObjective

public int getUnchangedObjective()
Returns:
Returns the unchangedObjective.

setUnchangedObjective

public void setUnchangedObjective(int unchangedObjective)
Parameters:
unchangedObjective - The unchangedObjective to set.