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.sequenceScores.differentiable
Class AbstractDifferentiableSequenceScore

    java.lang.Object
      de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore

All Implemented Interfaces:
  DifferentiableSequenceScore, SequenceScore, Storable, Cloneable

Direct Known Subclasses:
  AbstractDifferentiableStatisticalModel, IndependentProductDiffSS, LogisticDiffSS, MultiDimensionalSequenceWrapperDiffSM, UniformDiffSS

    public abstract class AbstractDifferentiableSequenceScore

extends Object
implements DifferentiableSequenceScore

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

Author:
  Jens Keilwagen, Jan Grau

Field Summary
`protected AlphabetContainer` | `alphabets` The `AlphabetContainer` of this `AbstractDifferentiableSequenceScore` .
`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.sequenceScores.differentiable.DifferentiableSequenceScore
`UNKNOWN`

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

Method Summary
`AbstractDifferentiableSequenceScore` | `clone()` Creates a clone (deep copy) of the current `DifferentiableSequenceScore` 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 container of alphabets that were used when constructing the instance.
`ResultSet` | `getCharacteristics()` Returns some information characterizing or describing the current instance.
`double` | `getInitialClassParam(double classProb)` Returns the initial class parameter for the class this `DifferentiableSequenceScore` is responsible for, based on the class probability `classProb`.
`int` | `getLength()` Returns the length of sequences this instance can score.
`double` | `getLogScoreAndPartialDerivation(Sequence seq, int startpos, int endpos, IntList indices, DoubleList partialDer)` Returns the logarithmic score for a `Sequence` beginning at position `start` in the `Sequence` and fills lists with the indices and the partial derivations.
`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.
`double[]` | `getLogScoreFor(DataSet data)` This method computes the logarithm of the scores of all sequences in the given sample.
`void` | `getLogScoreFor(DataSet data, double[] res)` This method computes and stores the logarithm of the scores for any sequence in the sample in the given `double`-array.
`double` | `getLogScoreFor(Sequence seq)` Returns the logarithmic score for the `Sequence` `seq`.
`double` | `getLogScoreFor(Sequence seq, int startpos, int endpos)` Returns the logarithmic score for the `Sequence` `seq` beginning at position `start` in the `Sequence`.
`int` | `getNumberOfRecommendedStarts()` This method returns the number of recommended optimization starts.
`static int` | `getNumberOfStarts(DifferentiableSequenceScore[] score)` Returns the number of recommended starts in a numerical optimization.
`NumericalResultSet` | `getNumericalCharacteristics()` Returns the subset of numerical values that are also returned by `SequenceScore.getCharacteristics()`.

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

Methods inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore
`getCurrentParameterValues, getLogScoreAndPartialDerivation, getNumberOfParameters, initializeFunction, initializeFunctionRandomly, setParameters`

Methods inherited from interface de.jstacs.sequenceScores.SequenceScore
`getInstanceName, getLogScoreFor, isInitialized`

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:
    `DifferentiableSequenceScore.getCurrentParameterValues()`

### alphabets

    protected AlphabetContainer alphabets

  The `AlphabetContainer` of this `AbstractDifferentiableSequenceScore` .

### length

    protected int length

  The length of the modeled sequences.

Constructor Detail

### AbstractDifferentiableSequenceScore

    public AbstractDifferentiableSequenceScore(AlphabetContainer alphabets,
                                               int length)
                                        throws IllegalArgumentException

  The main constructor.

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

### AbstractDifferentiableSequenceScore

    public AbstractDifferentiableSequenceScore(StringBuffer xml)
                                        throws NonParsableException

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

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

Method Detail

### getNumberOfStarts

    public static final int getNumberOfStarts(DifferentiableSequenceScore[] score)

  Returns the number of recommended starts in a numerical optimization.

  Parameters:
    `score` - the scoring functions
  Returns:
    the number of recommended starts
  See Also:
    `DifferentiableSequenceScore.getNumberOfRecommendedStarts()`

### clone

    public AbstractDifferentiableSequenceScore clone()
                                              throws CloneNotSupportedException

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

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

### 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:
    `AbstractDifferentiableSequenceScore(StringBuffer)`

### getAlphabetContainer

    public final AlphabetContainer getAlphabetContainer()

  Description copied from interface: `SequenceScore`
  Returns the container of alphabets that were used when constructing the instance.

  Specified by:
    `getAlphabetContainer` in interface `SequenceScore`
  Returns:
    the container of alphabets that were used when constructing the instance

### getLength

    public int getLength()

  Description copied from interface: `SequenceScore`
  Returns the length of sequences this instance can score. Instances that can only score sequences of defined length are e.g. PWM or inhomogeneous Markov models. If the instance can score sequences of arbitrary length, e.g. homogeneous Markov models, this method returns 0 (zero).

  Specified by:
    `getLength` in interface `SequenceScore`
  Returns:
    the length of sequences the instance can score

### getLogScoreFor

    public final double getLogScoreFor(Sequence seq)

  Description copied from interface: `SequenceScore`
  Returns the logarithmic score for the `Sequence` `seq`.

  Specified by:
    `getLogScoreFor` in interface `SequenceScore`
  Parameters:
    `seq` - the sequence
  Returns:
    the logarithmic score for the sequence

### getLogScoreFor

    public double getLogScoreFor(Sequence seq,
                                 int startpos,
                                 int endpos)
                          throws WrongLengthException

  Description copied from interface: `SequenceScore`
  Returns the logarithmic score for the `Sequence` `seq` beginning at position `start` in the `Sequence`.

  Specified by:
    `getLogScoreFor` in interface `SequenceScore`
  Parameters:
    `seq` - the `Sequence`
    `startpos` - the start position in the `Sequence`
    `endpos` - the end position (inclusive) in the `Sequence`
  Returns:
    the logarithmic score for the `Sequence`
  Throws:
    `WrongLengthException`

### getLogScoreAndPartialDerivation

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

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

  Specified by:
    `getLogScoreAndPartialDerivation` in interface `DifferentiableSequenceScore`
  Parameters:
    `seq` - the `Sequence`
    `indices` - an `IntList` of indices, after method invocation the list should contain the indices `i` where is not zero
    `partialDer` - a `DoubleList` of partial derivations, after method invocation the list should contain the corresponding that are not zero
  Returns:
    the logarithmic score for the `Sequence`

### getLogScoreAndPartialDerivation

    public double getLogScoreAndPartialDerivation(Sequence seq,
                                                  int startpos,
                                                  int endpos,
                                                  IntList indices,
                                                  DoubleList partialDer)
                                           throws WrongLengthException

  Description copied from interface: `DifferentiableSequenceScore`
  Returns the logarithmic score for a `Sequence` beginning at position `start` in the `Sequence` and fills lists with the indices and the partial derivations.

  Specified by:
    `getLogScoreAndPartialDerivation` in interface `DifferentiableSequenceScore`
  Parameters:
    `seq` - the `Sequence`
    `startpos` - the start position in the `Sequence`
    `endpos` - the end position (inclusive) in the `Sequence`
    `indices` - an `IntList` of indices, after method invocation the list should contain the indices i where is not zero
    `partialDer` - a `DoubleList` of partial derivations, after method invocation the list should contain the corresponding that are not zero
  Returns:
    the logarithmic score for the `Sequence`
  Throws:
    `WrongLengthException`

### getNumberOfRecommendedStarts

    public int getNumberOfRecommendedStarts()

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

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

### getInitialClassParam

    public double getInitialClassParam(double classProb)

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

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

### getLogScoreFor

    public double[] getLogScoreFor(DataSet data)
                            throws Exception

  Description copied from interface: `SequenceScore`
  This method computes the logarithm of the scores of all sequences in the given sample. The values are stored in an array according to the index of the respective sequence in the sample.
  The score for any sequence shall be computed independent of all other sequences in the sample. So the result should be exactly the same as for the method `SequenceScore.getLogScoreFor(Sequence)`.

  Specified by:
    `getLogScoreFor` in interface `SequenceScore`
  Parameters:
    `data` - the sample of sequences
  Returns:
    an array containing the logarithm of the score of all sequences of the sample
  Throws:
    `Exception` - if something went wrong
  See Also:
    `SequenceScore.getLogScoreFor(Sequence)`

### getLogScoreFor

    public void getLogScoreFor(DataSet data,
                               double[] res)
                        throws Exception

  Description copied from interface: `SequenceScore`
  This method computes and stores the logarithm of the scores for any sequence in the sample in the given `double`-array.
  The score for any sequence shall be computed independent of all other sequences in the sample. So the result should be exactly the same as for the method `SequenceScore.getLogScoreFor(Sequence)`.

  Specified by:
    `getLogScoreFor` in interface `SequenceScore`
  Parameters:
    `data` - the sample of sequences
    `res` - the array for the results, has to have length `data.getNumberOfElements()` (which returns the number of sequences in the sample)
  Throws:
    `Exception` - if something went wrong
  See Also:
    `SequenceScore.getLogScoreFor(Sequence)`, `SequenceScore.getLogScoreFor(DataSet)`

### getCharacteristics

    public ResultSet getCharacteristics()
                                 throws Exception

  Description copied from interface: `SequenceScore`
  Returns some information characterizing or describing the current instance. This could be e.g. the number of edges for a Bayesian network or an image showing some representation of the instance. The set of characteristics should always include the XML-representation of the instance. The corresponding result type is `StorableResult`.

  Specified by:
    `getCharacteristics` in interface `SequenceScore`
  Returns:
    the characteristics of the current instance
  Throws:
    `Exception` - if some of the characteristics could not be defined
  See Also:
    `StorableResult`

### getNumericalCharacteristics

    public NumericalResultSet getNumericalCharacteristics()
                                                   throws Exception

  Description copied from interface: `SequenceScore`
  Returns the subset of numerical values that are also returned by `SequenceScore.getCharacteristics()`.

  Specified by:
    `getNumericalCharacteristics` in interface `SequenceScore`
  Returns:
    the numerical characteristics of the current instance
  Throws:
    `Exception` - if some of the characteristics could not be defined

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