de.jstacs.classifiers.differentiableSequenceScoreBased.sampling
Class SamplingGenDisMixClassifier

java.lang.Object
  extended by de.jstacs.classifiers.AbstractClassifier
      extended by de.jstacs.classifiers.AbstractScoreBasedClassifier
          extended by de.jstacs.classifiers.differentiableSequenceScoreBased.sampling.SamplingScoreBasedClassifier
              extended by de.jstacs.classifiers.differentiableSequenceScoreBased.sampling.SamplingGenDisMixClassifier
All Implemented Interfaces:
Storable, Cloneable

public class SamplingGenDisMixClassifier
extends SamplingScoreBasedClassifier

A classifier that samples its parameters from a LogGenDisMixFunction using the Metropolis-Hastings algorithm. For details on the algorithm see SamplingScoreBasedClassifier. The LogGenDisMixFunction includes several known posterior distributions, including the posterior (LearningPrinciple.MAP) and the supervised posterior (LearningPrinciple.MSP). For non-uniform values of the mixture parameters beta the distribution we sample from is less well defined, although sampling is possible in general.

Author:
Jan Grau

Nested Class Summary
 
Nested classes/interfaces inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.sampling.SamplingScoreBasedClassifier
SamplingScoreBasedClassifier.DiffSMSamplingComponent, SamplingScoreBasedClassifier.SamplingScheme
 
Nested classes/interfaces inherited from class de.jstacs.classifiers.AbstractScoreBasedClassifier
AbstractScoreBasedClassifier.DoubleTableResult
 
Field Summary
 
Fields inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.sampling.SamplingScoreBasedClassifier
burnInTest, currentParameters, currentScore, initParameters, lastParameters, lastScore, params, previousParameters, scoringFunctions
 
Constructor Summary
SamplingGenDisMixClassifier(SamplingGenDisMixClassifierParameterSet params, BurnInTest burnInTest, double[] classVariances, LogPrior prior, double[] beta, SamplingDifferentiableStatisticalModel... scoringFunctions)
          Creates a new SamplingGenDisMixClassifier using the external parameters params, a burn-in test, a set of sampling variances for the different classes, a prior on the parameters, weights beta for the three components of the LogGenDisMixFunction, i.e., likelihood, conditional likelihood, and prior, and scoring functions that model the distribution for each of the classes.
SamplingGenDisMixClassifier(SamplingGenDisMixClassifierParameterSet params, BurnInTest burnInTest, double[] classVariances, LogPrior prior, LearningPrinciple principle, SamplingDifferentiableStatisticalModel... scoringFunctions)
          Creates a new SamplingGenDisMixClassifier using the external parameters params, a burn-in test, a set of sampling variances for the different classes, a prior on the parameters, a learning principle, and scoring functions that model the distribution for each of the classes.
SamplingGenDisMixClassifier(StringBuffer xml)
          Creates a new SamplingGenDisMixClassifier from its XML-representation
 
Method Summary
protected  void extractFurtherClassifierInfosFromXML(StringBuffer xml)
          Extracts further information of a classifier from an XML representation.
 GenDisMixClassifier getClassifierForBestParameters(GenDisMixClassifierParameterSet params)
          Returns a standard, i.e., non-sampling, GenDisMixClassifier, where the parameters are set to those that yielded the maximum value of the objective functions among all sampled parameter values.
 GenDisMixClassifier getClassifierForMeanParameters(GenDisMixClassifierParameterSet params, boolean testBurnIn, int minBurnInSteps)
          Returns a standard, i.e., non-sampling, GenDisMixClassifier, where the parameters are set to the mean values over all sampled parameter values in the stationary phase.
protected  DiffSSBasedOptimizableFunction getFunction(DataSet[] data, double[][] weights)
          Returns the function that should be sampled from.
protected  StringBuffer getFurtherClassifierInfos()
          This method returns further information of a classifier as a StringBuffer.
protected  String getXMLTag()
          Returns the String that is used as tag for the XML representation of the classifier.
protected  double modifyFunctionValue(double value)
          Allows for a modification of the value returned by the function obtained by SamplingScoreBasedClassifier.getFunction(DataSet[], double[][]).
 
Methods inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.sampling.SamplingScoreBasedClassifier
doOneSamplingStep, doSingleSampling, getBestParameters, getClassifierAnnotation, getDeleteOnExit, getInstanceName, getMeanParameters, getNumericalCharacteristics, getSamplingComponent, getScore, getScores, getTempDir, init, isInitialized, joinAndSetParameterFiles, precomputeBurnInLength, sample, sampleNSteps, setDeleteOnExit, setInitParameters, setTempDir, train
 
Methods inherited from class de.jstacs.classifiers.AbstractScoreBasedClassifier
check, check, classify, classify, clone, createDefaultClassWeights, getClassWeight, getClassWeights, getMultiClassScores, getNumberOfClasses, getPValue, getPValue, getResults, getScore, setClassWeights, setClassWeights, setThresholdClassWeights
 
Methods inherited from class de.jstacs.classifiers.AbstractClassifier
classify, evaluate, evaluate, getAlphabetContainer, getCharacteristics, getLength, toXML, train
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SamplingGenDisMixClassifier

public SamplingGenDisMixClassifier(SamplingGenDisMixClassifierParameterSet params,
                                   BurnInTest burnInTest,
                                   double[] classVariances,
                                   LogPrior prior,
                                   double[] beta,
                                   SamplingDifferentiableStatisticalModel... scoringFunctions)
                            throws CloneNotSupportedException
Creates a new SamplingGenDisMixClassifier using the external parameters params, a burn-in test, a set of sampling variances for the different classes, a prior on the parameters, weights beta for the three components of the LogGenDisMixFunction, i.e., likelihood, conditional likelihood, and prior, and scoring functions that model the distribution for each of the classes.

Parameters:
params - the external parameters
burnInTest - the burn-in test, or null for no burn-in test
classVariances - the sampling variances for the parameters in the different classes
prior - the prior on the parameters
beta - The weights of the three components of the LogGenDisMixFunction
scoringFunctions - the scoring functions for the different classes
Throws:
CloneNotSupportedException - if the scoring functions could not be cloned

SamplingGenDisMixClassifier

public SamplingGenDisMixClassifier(SamplingGenDisMixClassifierParameterSet params,
                                   BurnInTest burnInTest,
                                   double[] classVariances,
                                   LogPrior prior,
                                   LearningPrinciple principle,
                                   SamplingDifferentiableStatisticalModel... scoringFunctions)
                            throws CloneNotSupportedException
Creates a new SamplingGenDisMixClassifier using the external parameters params, a burn-in test, a set of sampling variances for the different classes, a prior on the parameters, a learning principle, and scoring functions that model the distribution for each of the classes.

Parameters:
params - the external parameters
burnInTest - the burn-in test, or null for no burn-in test
classVariances - the sampling variances for the parameters in the different classes
prior - the prior on the parameters
principle - the learning principle, i.e., the objective function we sample from
scoringFunctions - the scoring functions for the different classes
Throws:
CloneNotSupportedException - if the scoring functions could not be cloned

SamplingGenDisMixClassifier

public SamplingGenDisMixClassifier(StringBuffer xml)
                            throws NonParsableException
Creates a new SamplingGenDisMixClassifier from its XML-representation

Parameters:
xml - the XML-representation
Throws:
NonParsableException - if xml could not be parsed
Method Detail

getFunction

protected DiffSSBasedOptimizableFunction getFunction(DataSet[] data,
                                                     double[][] weights)
                                              throws Exception
Description copied from class: SamplingScoreBasedClassifier
Returns the function that should be sampled from.

Specified by:
getFunction in class SamplingScoreBasedClassifier
Parameters:
data - the samples
weights - the weights of the sequences of the samples
Returns:
the function that should be sampled from
Throws:
Exception - if the function could not be created

modifyFunctionValue

protected double modifyFunctionValue(double value)
Description copied from class: SamplingScoreBasedClassifier
Allows for a modification of the value returned by the function obtained by SamplingScoreBasedClassifier.getFunction(DataSet[], double[][]). This is for instance necessary in case of LogGenDisMixFunction to obtain a proper posterior or supervised posterior.

Overrides:
modifyFunctionValue in class SamplingScoreBasedClassifier
Parameters:
value - the original value
Returns:
the modified value

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 AbstractClassifier
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 SamplingScoreBasedClassifier
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 SamplingScoreBasedClassifier
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)

getClassifierForBestParameters

public GenDisMixClassifier getClassifierForBestParameters(GenDisMixClassifierParameterSet params)
                                                   throws Exception
Returns a standard, i.e., non-sampling, GenDisMixClassifier, where the parameters are set to those that yielded the maximum value of the objective functions among all sampled parameter values.

Parameters:
params - the external parameters of the GenDisMixClassifier
Returns:
the GenDisMixClassifier with set parameter values
Throws:
Exception - if the GenDisMixClassifier could not be created

getClassifierForMeanParameters

public GenDisMixClassifier getClassifierForMeanParameters(GenDisMixClassifierParameterSet params,
                                                          boolean testBurnIn,
                                                          int minBurnInSteps)
                                                   throws Exception
Returns a standard, i.e., non-sampling, GenDisMixClassifier, where the parameters are set to the mean values over all sampled parameter values in the stationary phase.

Parameters:
params - the external parameters of the GenDisMixClassifier
testBurnIn - if burn-in phase is tested, otherwise parameters starting from index minBurnInSteps are considered
minBurnInSteps - the minimum number of steps before the stationary phase
Returns:
the GenDisMixClassifier with set parameter values
Throws:
Exception - if the GenDisMixClassifier could not be created