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.classifier.scoringFunctionBased.gendismix
Class GenDisMixClassifier

    java.lang.Object
      de.jstacs.classifier.AbstractClassifier
          de.jstacs.classifier.AbstractScoreBasedClassifier
              de.jstacs.classifier.scoringFunctionBased.ScoreClassifier
                  de.jstacs.classifier.scoringFunctionBased.gendismix.GenDisMixClassifier

All Implemented Interfaces:
  Storable, Cloneable

Direct Known Subclasses:
  MSPClassifier

    public class GenDisMixClassifier

extends ScoreClassifier

This class implements a classifier the optimizes the following function

The weights have to sum to 1. For special weights the optimization turns out to be well known

- if the weights are (0,1,0), one obtains maximum likelihood,
- if the weights are (0,0.5,0.5), one obtains maximum a posteriori,
- if the weights are (1,0,0), one obtains maximum conditional likelihood,
- if the weights are (0.5,0,0.5), one obtains maximum supervised posterior,
- if the =0, one obtains the generative-discriminative trade-off,
- if the =0.5, one obtains the penalized generative-discriminative trade-off.

Of course, there are also some very interesting cases with other weights.

Author:
  Jens Keilwagen
See Also:
  `LearningPrinciple`, `LogGenDisMixFunction`

Nested Class Summary

Nested classes/interfaces inherited from class de.jstacs.classifier.AbstractScoreBasedClassifier
`AbstractScoreBasedClassifier.DoubleTableResult`

Field Summary
`protected double[]` | `beta` The weights that determine a point of the simplex that corresponds to the function that is optimized by this classifier.
`protected LogGenDisMixFunction` | `function` The function that is optimized in this classifier.
`protected LogPrior` | `prior` The prior that is used in this classifier.

Fields inherited from class de.jstacs.classifier.scoringFunctionBased.ScoreClassifier
`hasBeenOptimized, NOT_TRAINED_VALUE, params, score, sostream, template`

Constructor Summary
`` | `GenDisMixClassifier(GenDisMixClassifierParameterSet params, LogPrior prior, double[] beta, NormalizableScoringFunction... score)` The main constructor.
`` | `GenDisMixClassifier(GenDisMixClassifierParameterSet params, LogPrior prior, double lastScore, double[] beta, NormalizableScoringFunction... score)` This constructor creates an instance and sets the value of the last (external) optimization.
`protected` | `GenDisMixClassifier(GenDisMixClassifierParameterSet params, LogPrior prior, double lastScore, double[] beta, ScoringFunction... score)` This constructor creates an instance and sets the value of the last (external) optimization.
`` | `GenDisMixClassifier(GenDisMixClassifierParameterSet params, LogPrior prior, double genBeta, double disBeta, double priorBeta, NormalizableScoringFunction... score)` This convenience constructor agglomerates the `genBeta, disBeta,` and `priorBeta` into an array and calls the main constructor.
`` | `GenDisMixClassifier(GenDisMixClassifierParameterSet params, LogPrior prior, LearningPrinciple key, NormalizableScoringFunction... score)` This convenience constructor creates an array of weights for an elementary learning principle and calls the main constructor.
`` | `GenDisMixClassifier(StringBuffer xml)` This is the constructor for `Storable`.

Method Summary
`GenDisMixClassifier` | `clone()`
`static GenDisMixClassifier[]` | `create(GenDisMixClassifierParameterSet params, LogPrior prior, double[] weights, NormalizableScoringFunction[]... functions)` This method creates an array of GenDisMixClassifiers by using the cross-product of the given NormalizableScoringFunctions.
`protected void` | `extractFurtherClassifierInfosFromXML(StringBuffer xml)` Extracts further information of a classifier from an XML representation.
`protected LogGenDisMixFunction` | `getFunction(Sample[] data, double[][] weights)` Returns the function that should be optimized.
`protected StringBuffer` | `getFurtherClassifierInfos()` This method returns further information of a classifier as a `StringBuffer`.
`String` | `getInstanceName()` Returns a short description of the classifier.
`int` | `getNumberOfThreads()` This method returns the number of used threads while optimization.
`protected String` | `getXMLTag()` Returns the `String` that is used as tag for the XML representation of the classifier.
`void` | `setNumberOfThreads(int threads)` This method allows to set the number of threads used while optimization.
`void` | `setPrior(LogPrior prior)` This method set a new prior that should be used for optimization.
`void` | `setWeights(double... beta)` This method set the weights for the summand of the function.
`String` | `toString()`

Methods inherited from class de.jstacs.classifier.scoringFunctionBased.ScoreClassifier
`createStructure, createStructure, doOptimization, getClassifierAnnotation, getCurrentParameterSet, getLastScore, getNumericalCharacteristics, getScore, getScoringFunction, getScoringFunctions, hasBeenOptimized, initUsingParameters, isTrained, preoptimize, setOutputStream, train`

Methods inherited from class de.jstacs.classifier.AbstractScoreBasedClassifier
`check, check, classify, classify, createDefaultClassWeights, getClassWeight, getClassWeights, getNumberOfClasses, getPValue, getPValue, getResults, getScore, getScores, setClassWeights, setClassWeights, setThresholdClassWeights, test`

Methods inherited from class de.jstacs.classifier.AbstractClassifier
`classify, evaluate, evaluateAll, getAlphabetContainer, getCharacteristics, getClassificationRate, getLength, getMeasuresForEvaluate, getMeasuresForEvaluateAll, setNewAlphabetContainerInstance, toXML, train`

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

Field Detail

### prior

    protected LogPrior prior

  The prior that is used in this classifier.

### function

    protected LogGenDisMixFunction function

  The function that is optimized in this classifier.

### beta

    protected double[] beta

  The weights that determine a point of the simplex that corresponds to the function that is optimized by this classifier.

Constructor Detail

### GenDisMixClassifier

    protected GenDisMixClassifier(GenDisMixClassifierParameterSet params,
                                  LogPrior prior,
                                  double lastScore,
                                  double[] beta,
                                  ScoringFunction... score)
                           throws CloneNotSupportedException

  This constructor creates an instance and sets the value of the last (external) optimization. This constructor should only be used if it is clear that now generative part is used in the objective function.

  Parameters:
    `params` - the common parameters
    `prior` - the prior for the parameters of the classifier
    `lastScore` - the score of the last optimization
    `beta` - the weights for log likelihood, log conditional likelihood and log prior
    `score` - the functions for the classes
  Throws:
    `CloneNotSupportedException` - if an instance could not be clone

### GenDisMixClassifier

    public GenDisMixClassifier(GenDisMixClassifierParameterSet params,
                               LogPrior prior,
                               double lastScore,
                               double[] beta,
                               NormalizableScoringFunction... score)
                        throws CloneNotSupportedException

  This constructor creates an instance and sets the value of the last (external) optimization.

  Parameters:
    `params` - the common parameters
    `prior` - the prior for the parameters of the classifier
    `lastScore` - the score of the last optimization
    `beta` - the weights for log likelihood, log conditional likelihood and log prior
    `score` - the functions for the classes
  Throws:
    `CloneNotSupportedException` - if an instance could not be clone

### GenDisMixClassifier

    public GenDisMixClassifier(GenDisMixClassifierParameterSet params,
                               LogPrior prior,
                               double[] beta,
                               NormalizableScoringFunction... score)
                        throws CloneNotSupportedException

  The main constructor.

  Parameters:
    `params` - the common parameters
    `prior` - the prior for the parameters of the classifier
    `beta` - the weights for log likelihood, log conditional likelihood and log prior
    `score` - the functions for the classes
  Throws:
    `CloneNotSupportedException` - if an instance could not be clone

### GenDisMixClassifier

    public GenDisMixClassifier(GenDisMixClassifierParameterSet params,
                               LogPrior prior,
                               double genBeta,
                               double disBeta,
                               double priorBeta,
                               NormalizableScoringFunction... score)
                        throws CloneNotSupportedException

  This convenience constructor agglomerates the `genBeta, disBeta,` and `priorBeta` into an array and calls the main constructor.

  Parameters:
    `params` - the common parameters
    `prior` - the prior for the parameters of the classifier
    `genBeta` - the weight for the log likelihood
    `disBeta` - the weight for the log conditional likelihood
    `priorBeta` - the weight for the log prior
    `score` - the functions for the classes
  Throws:
    `CloneNotSupportedException` - if an instance could not be clone

### GenDisMixClassifier

    public GenDisMixClassifier(GenDisMixClassifierParameterSet params,
                               LogPrior prior,
                               LearningPrinciple key,
                               NormalizableScoringFunction... score)
                        throws CloneNotSupportedException

  This convenience constructor creates an array of weights for an elementary learning principle and calls the main constructor.

  Parameters:
    `params` - the common parameters
    `prior` - the prior for the parameters of the classifier
    `key` - the key for an elementary `LearningPrinciple`
    `score` - the functions for the classes
  Throws:
    `CloneNotSupportedException` - if an instance could not be clone
  See Also:
    `LearningPrinciple.getBeta(LearningPrinciple)`

### GenDisMixClassifier

    public GenDisMixClassifier(StringBuffer xml)
                        throws NonParsableException

  This is the constructor for `Storable`.

  Parameters:
    `xml` - the xml representation
  Throws:
    `NonParsableException` - if the representation could not be parsed.

Method Detail

### clone

    public GenDisMixClassifier clone()
                              throws CloneNotSupportedException

  Overrides:
    `clone` in class `ScoreClassifier`
  Throws:
    `CloneNotSupportedException`

### getFunction

    protected LogGenDisMixFunction getFunction(Sample[] data,
                                               double[][] weights)
                                        throws Exception

  Description copied from class: `ScoreClassifier`
  Returns the function that should be optimized.

  Specified by:
    `getFunction` in class `ScoreClassifier`
  Parameters:
    `data` - the samples
    `weights` - the weights of the sequences of the samples
  Returns:
    the function that should be optimized
  Throws:
    `Exception` - if something went wrong

### setPrior

    public void setPrior(LogPrior prior)

  This method set a new prior that should be used for optimization. Since it could not be ensured that the classifier is optimal now `isTrained` will return `false` after invoking this method.

  Parameters:
    `prior` - the new prior

### setWeights

    public void setWeights(double... beta)
                    throws IllegalArgumentException

  This method set the weights for the summand of the function. Since it could not be ensured that the classifier is optimal now `isTrained` will return `false` after invoking this method.

  Parameters:
    `beta` - the weights
  Throws:
    `IllegalArgumentException` - if the weights array is not correct
  See Also:
    `LearningPrinciple.getBeta(LearningPrinciple)`

### getXMLTag

    protected String getXMLTag()

  Description copied from class: `AbstractClassifier`
  Returns the `String` that is used as tag for the XML representation of the classifier. This method is used by the methods `AbstractClassifier.fromXML(StringBuffer)` and `AbstractClassifier.toXML()`.

  Specified by:
    `getXMLTag` in class `ScoreClassifier`
  Returns:
    the `String` that is used as tag for the XML representation of the classifier

### getFurtherClassifierInfos

    protected StringBuffer getFurtherClassifierInfos()

  Description copied from class: `AbstractClassifier`
  This method returns further information of a classifier as a `StringBuffer`. This method is used by the method `AbstractClassifier.toXML()` and should not be made public.

  Overrides:
    `getFurtherClassifierInfos` in class `ScoreClassifier`
  Returns:
    further information of a classifier as a `StringBuffer`
  See Also:
    `AbstractClassifier.toXML()`

### extractFurtherClassifierInfosFromXML

    protected void extractFurtherClassifierInfosFromXML(StringBuffer xml)
                                                 throws NonParsableException

  Description copied from class: `AbstractClassifier`
  Extracts further information of a classifier from an XML representation. This method is used by the method `AbstractClassifier.fromXML(StringBuffer)` and should not be made public.

  Overrides:
    `extractFurtherClassifierInfosFromXML` in class `ScoreClassifier`
  Parameters:
    `xml` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if the information could not be parsed out of the XML representation (the `StringBuffer` could not be parsed)
  See Also:
    `AbstractClassifier.fromXML(StringBuffer)`

### create

    public static GenDisMixClassifier[] create(GenDisMixClassifierParameterSet params,
                                               LogPrior prior,
                                               double[] weights,
                                               NormalizableScoringFunction[]... functions)
                                        throws CloneNotSupportedException

  This method creates an array of GenDisMixClassifiers by using the cross-product of the given NormalizableScoringFunctions.

  Parameters:
    `params` - the parameters that will be used in all classifiers
    `prior` - the prior that will be used in all classifiers
    `weights` - the weights that will be used in all classifiers
    `functions` - the NormalizableScoringFunctions
    1. functions[i] are the NormalizableScoringFunctions that can be used for class i
    2. functions.length has to be at least 2
  Returns:
    an array of GenDisMixClassifiers
  Throws:
    `CloneNotSupportedException` - if the some item could not be cloned
  See Also:
    `GenDisMixClassifier(GenDisMixClassifierParameterSet, LogPrior, double[], NormalizableScoringFunction[])`

### getInstanceName

    public String getInstanceName()

  Description copied from class: `AbstractClassifier`
  Returns a short description of the classifier.

  Overrides:
    `getInstanceName` in class `ScoreClassifier`
  Returns:
    a short description of the classifier

### getNumberOfThreads

    public int getNumberOfThreads()

  This method returns the number of used threads while optimization.

  Returns:
    the number of used threads while optimization

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### setNumberOfThreads

    public void setNumberOfThreads(int threads)
                            throws SimpleParameter.IllegalValueException

  This method allows to set the number of threads used while optimization.

  Parameters:
    `threads` - the number of threads
  Throws:
    `SimpleParameter.IllegalValueException` - if the number of threads is not possible

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