de.jstacs.classifier.scoringFunctionBased.logPrior
Class LogPrior

java.lang.Object
  extended by de.jstacs.algorithms.optimization.DifferentiableFunction
      extended by de.jstacs.classifier.scoringFunctionBased.logPrior.LogPrior
All Implemented Interfaces:
Function, Storable
Direct Known Subclasses:
CompositeLogPrior, DoesNothingLogPrior, SeparateLogPrior, SimpleGaussianSumLogPrior

public abstract class LogPrior
extends DifferentiableFunction
implements Storable

The abstract class for any log-prior used e.g. for maximum supervised posterior optimization.

Author:
Jens Keilwagen

Field Summary
static int UNKNOWN
          Sometimes the method Function.getDimensionOfScope() can not return a value.
 
Constructor Summary
LogPrior()
           
 
Method Summary
abstract  void addGradientFor(double[] params, double[] vector)
          Adds the gradient of the log-prior using the current parameters to a given vector.
 double[] evaluateGradientOfFunction(double[] params)
          Evaluates the gradient of a function at a certain vector (in mathematical sense) x, i.e., $\nabla f(\underline{x}) = \left(\frac{\partial f(\underline{x})}{\partial x_1},\ldots,\frac{\partial f(\underline{x})}{\partial x_n}\right)$.
abstract  String getInstanceName()
          Returns a short instance name.
abstract  LogPrior getNewInstance()
          This method returns an empty new instance of the current prior.
 void set(boolean freeParameters, ScoringFunction... funs)
          Resets all pre-computed values to their initial values using the ScoringFunctions funs.
abstract  StringBuffer toXML()
          Encodes the prior as an XML representation.
 
Methods inherited from class de.jstacs.algorithms.optimization.DifferentiableFunction
findOneDimensionalMin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jstacs.algorithms.optimization.Function
evaluateFunction, getDimensionOfScope
 

Field Detail

UNKNOWN

public static final int UNKNOWN
Sometimes the method Function.getDimensionOfScope() can not return a value. In these cases it is recommended to use this constant.

See Also:
Constant Field Values
Constructor Detail

LogPrior

public LogPrior()
Method Detail

addGradientFor

public abstract void addGradientFor(double[] params,
                                    double[] vector)
                             throws EvaluationException
Adds the gradient of the log-prior using the current parameters to a given vector.

Parameters:
params - the parameters
vector - the vector
Throws:
EvaluationException - if the gradient could not be evaluated

evaluateGradientOfFunction

public final double[] evaluateGradientOfFunction(double[] params)
                                          throws EvaluationException
Description copied from class: DifferentiableFunction
Evaluates the gradient of a function at a certain vector (in mathematical sense) x, i.e., $\nabla f(\underline{x}) = \left(\frac{\partial f(\underline{x})}{\partial x_1},\ldots,\frac{\partial f(\underline{x})}{\partial x_n}\right)$.

Specified by:
evaluateGradientOfFunction in class DifferentiableFunction
Parameters:
params - the current vector
Returns:
the evaluation of the gradient of a function, has dimension Function.getDimensionOfScope()
Throws:
EvaluationException - if there was something wrong during the evaluation of the gradient
See Also:
Function.getDimensionOfScope()

getNewInstance

public abstract LogPrior getNewInstance()
                                 throws CloneNotSupportedException
This method returns an empty new instance of the current prior. The method works similar to clone, but does not clone ScoringFunction s that may be inside the instance. The ScoringFunctions must be set by an invocation of the method set(boolean, ScoringFunction...).

Returns:
a new empty instance of the prior
Throws:
CloneNotSupportedException - if something went wrong while cloning
See Also:
set(boolean, ScoringFunction...)

set

public void set(boolean freeParameters,
                ScoringFunction... funs)
         throws Exception
Resets all pre-computed values to their initial values using the ScoringFunctions funs.

Parameters:
freeParameters - the switch for using only the free parameters or all parameters in a ScoringFunction
funs - the ScoringFunctions for the prior
Throws:
Exception - if the ScoringFunctions could not be set

toXML

public abstract StringBuffer toXML()
Encodes the prior as an XML representation. It does not encode all information, since the method set(boolean, ScoringFunction...) has to be invoked after decoding.

Specified by:
toXML in interface Storable
Returns:
the XML representation;

getInstanceName

public abstract String getInstanceName()
Returns a short instance name.

Returns:
a short instance name