de.jstacs.classifier.scoringFunctionBased.cll
Class NormConditionalLogLikelihood

java.lang.Object
  extended by de.jstacs.algorithms.optimization.DifferentiableFunction
      extended by de.jstacs.classifier.scoringFunctionBased.OptimizableFunction
          extended by de.jstacs.classifier.scoringFunctionBased.cll.NormConditionalLogLikelihood
All Implemented Interfaces:
Function

public class NormConditionalLogLikelihood
extends OptimizableFunction

This class implements the normalized log conditional likelihood. It can be used to maximize the parameters.

Author:
Jens Keilwagen

Constructor Summary
NormConditionalLogLikelihood(ScoringFunction[] score, Sample[] data, double[][] weights, boolean norm, boolean freeParams)
          The constructor creates an instance of the log conditional likelihood.
NormConditionalLogLikelihood(ScoringFunction[] score, Sample[] data, double[][] weights, LogPrior prior, boolean norm, boolean freeParams)
          The constructor creates an instance using the given prior.
 
Method Summary
 double evaluateFunction(double[] x)
          Evaluates the function at a certain vector (in mathematical sense) x
 double[] evaluateGradientOfFunction(double[] x)
          Evaluates the gradient of function at a certain vector (in mathematical sense) x
 double[] getClassParams(double[] params)
          Returns from the complete vector of parameters those that are for the classes.
 int getDimensionOfScope()
          Returns the dimension of the scope of the function.
 int getNumberOfStarts()
          Returns the number of starts that should be done for a good optimum.
 double[] getStartParams(boolean plugIn)
          Returns some start parameters.
 void getStartParams(boolean plugIn, double[] erg)
          This method enables the user to get the start parameters without creating a new array.
 void reset(ScoringFunction[] funs)
          Resets the scoringFunctions and all precomputed values.
 void setParams(double[] params)
          Sets the current values as parameters
 
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
 

Constructor Detail

NormConditionalLogLikelihood

public NormConditionalLogLikelihood(ScoringFunction[] score,
                                    Sample[] data,
                                    double[][] weights,
                                    boolean norm,
                                    boolean freeParams)
                             throws IllegalArgumentException,
                                    WrongAlphabetException
The constructor creates an instance of the log conditional likelihood.

Parameters:
score - the ScoringFunctions
data - the data
weights - the weights
norm - the switch for using the normalization (division by the number of sequences)
freeParams - the switch for using only the free parameters
Throws:
IllegalArgumentException
WrongAlphabetException

NormConditionalLogLikelihood

public NormConditionalLogLikelihood(ScoringFunction[] score,
                                    Sample[] data,
                                    double[][] weights,
                                    LogPrior prior,
                                    boolean norm,
                                    boolean freeParams)
                             throws IllegalArgumentException,
                                    WrongAlphabetException
The constructor creates an instance using the given prior.

Parameters:
score - the ScoringFunctions
data - the data
weights - the weights
prior - the prior
norm - the switch for using the normalization (division by the number of sequences)
freeParams - the switch for using only the free parameters
Throws:
IllegalArgumentException
WrongAlphabetException
Method Detail

evaluateGradientOfFunction

public double[] evaluateGradientOfFunction(double[] x)
                                    throws DimensionException,
                                           EvaluationException
Description copied from class: DifferentiableFunction
Evaluates the gradient of function at a certain vector (in mathematical sense) x

Specified by:
evaluateGradientOfFunction in class DifferentiableFunction
Parameters:
x - the current vector
Returns:
the elvaluation of the gradient of a function; has dimension getDimensionOfScope()
Throws:
DimensionException - if dim(x) != n, with f: R^n -> R
EvaluationException - if there was a mistake in evaluating the gradient
See Also:
Function.getDimensionOfScope()

evaluateFunction

public double evaluateFunction(double[] x)
                        throws DimensionException,
                               EvaluationException
Description copied from interface: Function
Evaluates the function at a certain vector (in mathematical sense) x

Parameters:
x - the current vector
Returns:
the elvaluation of the function
Throws:
DimensionException - if dim(x) != n, with f: R^n -> R
EvaluationException - if there was a mistake in evaluating the function

getDimensionOfScope

public int getDimensionOfScope()
Description copied from interface: Function
Returns the dimension of the scope of the function.

Returns:
dimension of the scope; n, with f: R^n -> R

getStartParams

public void getStartParams(boolean plugIn,
                           double[] erg)
                    throws Exception
This method enables the user to get the start parameters without creating a new array.

Parameters:
plugIn - a switch to decide whether to used plug-in parameters or not
erg - the array for the start parameters
Throws:
Exception - if the array is null or does not have the correct length
See Also:
getStartParams(boolean)

getStartParams

public double[] getStartParams(boolean plugIn)
                        throws Exception
Description copied from class: OptimizableFunction
Returns some start parameters.

Specified by:
getStartParams in class OptimizableFunction
Parameters:
plugIn - if some special parameters should be used as plug in parameter (e.g. MAP-parameters)
Returns:
some start parameters
Throws:
Exception - if something went wrong

setParams

public void setParams(double[] params)
               throws DimensionException
Description copied from class: OptimizableFunction
Sets the current values as parameters

Specified by:
setParams in class OptimizableFunction
Parameters:
params - the current values
Throws:
DimensionException - if the dimension of the current values does not match with the internal parameters

getClassParams

public double[] getClassParams(double[] params)
Description copied from class: OptimizableFunction
Returns from the complete vector of parameters those that are for the classes.

Specified by:
getClassParams in class OptimizableFunction
Parameters:
params - the current params
Returns:
the parameters for the classes

getNumberOfStarts

public int getNumberOfStarts()
Description copied from class: OptimizableFunction
Returns the number of starts that should be done for a good optimum. For concave or convex functions this number should be 1.

Specified by:
getNumberOfStarts in class OptimizableFunction
Returns:
the number of starts the Optimizer should be started to get a good optimum
See Also:
Optimizer

reset

public void reset(ScoringFunction[] funs)
           throws Exception
Description copied from class: OptimizableFunction
Resets the scoringFunctions and all precomputed values.

Specified by:
reset in class OptimizableFunction
Parameters:
funs - the array of scoringFunctions
Throws:
Exception - if something went wrong