de.jstacs.sequenceScores.statisticalModels.trainable.discrete.inhomogeneous
Class StructureLearner

java.lang.Object
  extended by de.jstacs.sequenceScores.statisticalModels.trainable.discrete.inhomogeneous.StructureLearner

public class StructureLearner
extends Object

This class can be used to learn the structure of any discrete model.

Author:
Jens Keilwagen

Nested Class Summary
static class StructureLearner.LearningType
          This enum defines the different types of learning that are possible with the StructureLearner.
static class StructureLearner.ModelType
          This enum defines the different types of models that can be learned with the StructureLearner.
 
Constructor Summary
StructureLearner(AlphabetContainer con, int length)
          Creates a StructureLearner with equivalent sample size (ess) = 0.
StructureLearner(AlphabetContainer con, int length, double ess)
          Creates a new StructureLearner for a given AlphabetContainer, a given length and a given equivalent sample size (ess).
 
Method Summary
 AlphabetContainer getAlphabetContainer()
          This method returns the AlphabetContainer of the StructureLearner.
 double getEss()
          This method returns the ess (equivalent sample size) of the StructureLearner.
 int[][] getStructure(DataSet data, double[] weights, StructureLearner.ModelType model, byte order, StructureLearner.LearningType method)
          This method finds the optimal structure of a model by using a given learning method (in some sense).
static int[][] getStructure(Tensor t, StructureLearner.ModelType model, byte order)
          This method can be used to determine the optimal structure of a model.
 SymmetricTensor getTensor(DataSet data, double[] weights, byte order, StructureLearner.LearningType method)
          This method can be used to compute a Tensor that can be used to determine the optimal structure.
 void setESS(double ess)
          This method sets the ess (equivalent sample size) of the StructureLearner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StructureLearner

public StructureLearner(AlphabetContainer con,
                        int length,
                        double ess)
                 throws IllegalArgumentException
Creates a new StructureLearner for a given AlphabetContainer, a given length and a given equivalent sample size (ess).

Parameters:
con - the alphabets this instance should use
length - the length
ess - the ess (equivalent sample size, has to be non-negative)
Throws:
IllegalArgumentException - if the AlphabetContainer is not discrete, the length is not matching with the AlphabetContainer or the ess is below 0

StructureLearner

public StructureLearner(AlphabetContainer con,
                        int length)
                 throws IllegalArgumentException
Creates a StructureLearner with equivalent sample size (ess) = 0.

Parameters:
con - the alphabets this instance should use
length - the length
Throws:
IllegalArgumentException - if the AlphabetContainer is not discrete or the length is not matching with the AlphabetContainer
See Also:
StructureLearner(AlphabetContainer, int, double)
Method Detail

getAlphabetContainer

public AlphabetContainer getAlphabetContainer()
This method returns the AlphabetContainer of the StructureLearner.

Returns:
the AlphabetContainer of the StructureLearner

getEss

public double getEss()
This method returns the ess (equivalent sample size) of the StructureLearner.

Returns:
the ess of the StructureLearner

setESS

public void setESS(double ess)
            throws IllegalArgumentException
This method sets the ess (equivalent sample size) of the StructureLearner.

Parameters:
ess - the ess of the StructureLearner
Throws:
IllegalArgumentException - if ess < 0

getStructure

public int[][] getStructure(DataSet data,
                            double[] weights,
                            StructureLearner.ModelType model,
                            byte order,
                            StructureLearner.LearningType method)
                     throws Exception
This method finds the optimal structure of a model by using a given learning method (in some sense).

Parameters:
data - the DataSet
weights - the weights
model - the kind of model
order - the Markov order
method - the learning method
Returns:
the optimal structure of the specified model (in some sense)
Throws:
Exception - if something went wrong
See Also:
getTensor(DataSet, double[], byte, LearningType), getStructure(Tensor, ModelType, byte)

getStructure

public static int[][] getStructure(Tensor t,
                                   StructureLearner.ModelType model,
                                   byte order)
                            throws Exception
This method can be used to determine the optimal structure of a model.

Parameters:
t - the tensor containing all relevant weights (includes the learning method for the structure)
model - the model type
order - the model order
Returns:
the optimal structure of the specified model
Throws:
Exception - if something in the algorithm went wrong
See Also:
getTensor(DataSet, double[], byte, LearningType)

getTensor

public SymmetricTensor getTensor(DataSet data,
                                 double[] weights,
                                 byte order,
                                 StructureLearner.LearningType method)
                          throws IllegalArgumentException,
                                 WrongAlphabetException
This method can be used to compute a Tensor that can be used to determine the optimal structure.

Parameters:
data - the data
weights - the weights
order - the Markov order
method - the learning type
Returns:
a tensor containing all values the are necessary to determine the optimal structure (includes the learning method for the structure)
Throws:
IllegalArgumentException - if something is wrong with the given arguments
WrongAlphabetException - if the AlphabetContainer of the data is not correct
See Also:
getStructure(Tensor, ModelType, byte)