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

## de.jstacs.scoringFunctions
Class AbstractNormalizableScoringFunction

    java.lang.Object
      de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction

All Implemented Interfaces:
  NormalizableScoringFunction, ScoringFunction, Storable, Cloneable

Direct Known Subclasses:
  AbstractMixtureScoringFunction, BayesianNetworkScoringFunction, IndependentProductScoringFunction, MRFScoringFunction, NormalizedScoringFunction, PositionScoringFunction, UniformScoringFunction, VariableLengthScoringFunction

    public abstract class AbstractNormalizableScoringFunction

extends Object
implements NormalizableScoringFunction

This class is the main part of any `ScoreClassifier`. It implements many methods of the interface `NormalizableScoringFunction`.

Author:
  Jens Keilwagen, Jan Grau

Field Summary
`protected AlphabetContainer` | `alphabets` The `AlphabetContainer` of this `NormalizableScoringFunction` .
`protected int` | `length` The length of the modeled sequences.
`protected static Random` | `r` This object can be used for drawing initial parameters.

Fields inherited from interface de.jstacs.scoringFunctions.ScoringFunction
`UNKNOWN`

Constructor Summary
`AbstractNormalizableScoringFunction(AlphabetContainer alphabets, int length)` The main constructor.
`AbstractNormalizableScoringFunction(StringBuffer xml)` This is the constructor for `Storable`.

Method Summary
`AbstractNormalizableScoringFunction` | `clone()` Creates a clone (deep copy) of the current `ScoringFunction` instance.
`protected abstract void` | `fromXML(StringBuffer xml)` This method is called in the constructor for the `Storable` interface to create a scoring function from a `StringBuffer`.
`AlphabetContainer` | `getAlphabetContainer()` Returns the `AlphabetContainer` for this `ScoringFunction`.
`double` | `getInitialClassParam(double classProb)` Returns the initial class parameter for the class this `ScoringFunction` is responsible for, based on the class probability `classProb`.
`int` | `getLength()` Returns the length of this `ScoringFunction`, i.e. the length of the `Sequence`s this `ScoringFunction` can handle.
`double` | `getLogScore(Sequence seq)` Returns the logarithmic score for a given `Sequence`.
`double` | `getLogScoreAndPartialDerivation(Sequence seq, IntList indices, DoubleList partialDer)` Returns the logarithmic score for a `Sequence` `seq` and fills lists with the indices and the partial derivations.
`int` | `getNumberOfRecommendedStarts()` This method returns the number of recommended optimization starts.
`boolean` | `isNormalized()` This method indicates whether the implemented score is already normalized to 1 or not.
`static boolean` | `isNormalized(NormalizableScoringFunction... function)` This method checks whether all given `NormalizableScoringFunction`s are normalized.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface de.jstacs.scoringFunctions.NormalizableScoringFunction
`addGradientOfLogPriorTerm, getEss, getLogPriorTerm, getNormalizationConstant, getPartialNormalizationConstant, getSizeOfEventSpaceForRandomVariablesOfParameter`

Methods inherited from interface de.jstacs.scoringFunctions.ScoringFunction
`getCurrentParameterValues, getInstanceName, getLogScore, getLogScoreAndPartialDerivation, getNumberOfParameters, initializeFunction, initializeFunctionRandomly, isInitialized, setParameters`

Methods inherited from interface de.jstacs.Storable
`toXML`

Field Detail

### r

    protected static final Random r

  This object can be used for drawing initial parameters.

  See Also:
    `ScoringFunction.getCurrentParameterValues()`

### alphabets

    protected AlphabetContainer alphabets

  The `AlphabetContainer` of this `NormalizableScoringFunction` .

### length

    protected int length

  The length of the modeled sequences.

Constructor Detail

### AbstractNormalizableScoringFunction

    public AbstractNormalizableScoringFunction(AlphabetContainer alphabets,
                                               int length)
                                        throws IllegalArgumentException

  The main constructor.

  Parameters:
    `alphabets` - the `AlphabetContainer` of this `ScoringFunction`
    `length` - the length of this `ScoringFunction`, i.e. the length of the modeled sequences
  Throws:
    `IllegalArgumentException` - if the length is negative or does not match with `AlphabetContainer.getPossibleLength()`

### AbstractNormalizableScoringFunction

    public AbstractNormalizableScoringFunction(StringBuffer xml)
                                        throws NonParsableException

  This is the constructor for `Storable`. Creates a new `AbstractNormalizableScoringFunction` out of a `StringBuffer` .

  Parameters:
    `xml` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if the XML representation could not be parsed

Method Detail

### clone

    public AbstractNormalizableScoringFunction clone()
                                              throws CloneNotSupportedException

  Description copied from interface: `ScoringFunction`
  Creates a clone (deep copy) of the current `ScoringFunction` instance.

  Specified by:
    `clone` in interface `ScoringFunction`
  Overrides:
    `clone` in class `Object`
  Returns:
    the cloned instance of the current `ScoringFunction`
  Throws:
    `CloneNotSupportedException` - if something went wrong while cloning the `ScoringFunction`

### fromXML

    protected abstract void fromXML(StringBuffer xml)
                             throws NonParsableException

  This method is called in the constructor for the `Storable` interface to create a scoring function from a `StringBuffer`.

  Parameters:
    `xml` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if the `StringBuffer` could not be parsed
  See Also:
    `AbstractNormalizableScoringFunction(StringBuffer)`

### getAlphabetContainer

    public final AlphabetContainer getAlphabetContainer()

  Description copied from interface: `ScoringFunction`
  Returns the `AlphabetContainer` for this `ScoringFunction`. Only `Sequence`s with a comparable `AlphabetContainer` can be modeled.

  Specified by:
    `getAlphabetContainer` in interface `ScoringFunction`
  Returns:
    the `AlphabetContainer`

### getLength

    public int getLength()

  Description copied from interface: `ScoringFunction`
  Returns the length of this `ScoringFunction`, i.e. the length of the `Sequence`s this `ScoringFunction` can handle. For homogeneous `ScoringFunction`s, i.e. `ScoringFunction`s that support `Sequence`s of different lengths, the method should return `0`.

  Specified by:
    `getLength` in interface `ScoringFunction`
  Returns:
    the length of this `ScoringFunction`

### getLogScore

    public final double getLogScore(Sequence seq)

  Returns the logarithmic score for a given `Sequence`.

  Specified by:
    `getLogScore` in interface `ScoringFunction`
  Parameters:
    `seq` - the `Sequence`
  Returns:
    the log score for the `Sequence`

### getLogScoreAndPartialDerivation

    public final double getLogScoreAndPartialDerivation(Sequence seq,
                                                        IntList indices,
                                                        DoubleList partialDer)

  Description copied from interface: `ScoringFunction`
  Returns the logarithmic score for a `Sequence` `seq` and fills lists with the indices and the partial derivations.

  Specified by:
    `getLogScoreAndPartialDerivation` in interface `ScoringFunction`
  Parameters:
    `seq` - the `Sequence`
    `indices` - an `IntList` of indices, after method invocation the list should contain the indices `i` where `\frac{\partial \log score(seq)}{\partial \lambda_i}` is not zero
    `partialDer` - a `DoubleList` of partial derivations, after method invocation the list should contain the corresponding `\frac{\partial \log score(seq)}{\partial \lambda_i}`
  Returns:
    the logarithmic score for the `Sequence`

### getNumberOfRecommendedStarts

    public int getNumberOfRecommendedStarts()

  Description copied from interface: `ScoringFunction`
  This method returns the number of recommended optimization starts. The standard implementation returns 1.

  Specified by:
    `getNumberOfRecommendedStarts` in interface `ScoringFunction`
  Returns:
    the number of recommended optimization starts

### isNormalized

    public boolean isNormalized()

  Description copied from interface: `NormalizableScoringFunction`
  This method indicates whether the implemented score is already normalized to 1 or not. The standard implementation returns `false`.

  Specified by:
    `isNormalized` in interface `NormalizableScoringFunction`
  Returns:
    `true` if the implemented score is already normalized to 1, `false` otherwise

### isNormalized

    public static boolean isNormalized(NormalizableScoringFunction... function)

  This method checks whether all given `NormalizableScoringFunction`s are normalized.

  Parameters:
    `function` - the `NormalizableScoringFunction`s to be checked
  Returns:
    `true` if all `NormalizableScoringFunction`s are already normalized, otherwise `false`
  See Also:
    `NormalizableScoringFunction.isNormalized()`

### getInitialClassParam

    public double getInitialClassParam(double classProb)

  Description copied from interface: `ScoringFunction`
  Returns the initial class parameter for the class this `ScoringFunction` is responsible for, based on the class probability `classProb`.

  Specified by:
    `getInitialClassParam` in interface `NormalizableScoringFunction`
  Specified by:
    `getInitialClassParam` in interface `ScoringFunction`
  Parameters:
    `classProb` - the class probability
  Returns:
    the initial class parameter

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