Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## calhoun.analysis.crf.solver
Class StandardOptimizer

    java.lang.Object
      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:

- `debugLevel` - explicitly sets the debug level in the underlying L-BFGS solver. Normally it is set based on the debug level for this object.
- `epsForConvergence` - epsilon value used to determine when to halt the optimzation and declase convergence. Defaults to 0.0001.
- `fixFirstWeight` - if true, the first feature weight will be fixed at 1.0 and will not be allowed to change during the optimization
- `maxIters` - The maximum number of iterations (objective function evaluations) to attempt
- `mForHessian` - sets the `mForHession` parameter in the underlying L-BFGS solver. Defaults to 20.
- `quadraticRegularization` - if set to a nonzero value, regularizes feature weights by imposing a penalty on the objective function based on the absolute sizes of the weights. Can help in cases where weights get very large.
- `requireConverge` - if true, throws an error if convergence is not reached in the maximum number of iterations. Otherwise, the current feature weights are returned when `maxIters` is reached.
- `starts` - an initial set of guesses at feature weights. Defaults to 1.0
- `unchangedObjective` - the number of times the objectiveFunction must return an identical value before the optimization is assumed to have converged. This protects against a situation where the epsForConvergence is set low enough that even the smallest possible changes in weights can't find an optimum. Defaults to 5

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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD