Class SimpleDistributionTrainerContext
- java.lang.Object
-
- org.biojava.bio.dist.SimpleDistributionTrainerContext
-
- All Implemented Interfaces:
Serializable,DistributionTrainerContext
- Direct Known Subclasses:
SimpleModelTrainer
public class SimpleDistributionTrainerContext extends Object implements DistributionTrainerContext, Serializable
A no-frills implementation of DistributionTrainerContext.- Since:
- 1.0
- Author:
- Matthew Pocock
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleDistributionTrainerContext()Create a new context with no initial distributions or trainers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCount(Distribution dist, Symbol sym, double times)Registers that sym was counted in this state.voidclearCounts()Clears all of the counts to zero.doublegetCount(Distribution dist, Symbol sym)Return the number of counts of a particular symbol which will be used to train the specified distribution.doublegetNullModelWeight()Return the number of pseudocounts added to the distribution when training.DistributionTrainergetTrainer(Distribution dist)Return the Distribution trainer object from the current context.voidregisterDistribution(Distribution dist)Register a distribution object with this context.voidregisterTrainer(Distribution dist, DistributionTrainer trainer)Register a Distribution and an associated DistributionTrainer object.voidsetNullModelWeight(double nullModelWeight)Set the number of pseudocounts to add when training the distribution.voidtrain()Trains the Distribution, given a null model.
-
-
-
Constructor Detail
-
SimpleDistributionTrainerContext
public SimpleDistributionTrainerContext()
Create a new context with no initial distributions or trainers.
-
-
Method Detail
-
getNullModelWeight
public double getNullModelWeight()
Description copied from interface:DistributionTrainerContextReturn the number of pseudocounts added to the distribution when training.- Specified by:
getNullModelWeightin interfaceDistributionTrainerContext- Returns:
- the null model weight
-
setNullModelWeight
public void setNullModelWeight(double nullModelWeight)
Description copied from interface:DistributionTrainerContextSet the number of pseudocounts to add when training the distribution. These counts are added in proportion to the null model of the distribution being trained.- Specified by:
setNullModelWeightin interfaceDistributionTrainerContext- Parameters:
nullModelWeight- the new null model weight
-
registerDistribution
public void registerDistribution(Distribution dist)
Description copied from interface:DistributionTrainerContextRegister a distribution object with this context.
This method is a request to the context to register dist. If dist is already registered then this method should do nothing. If it is not registered, then it should invoke dist.registerWithTrainer
- Specified by:
registerDistributionin interfaceDistributionTrainerContext- Parameters:
dist- the Distribution to register
-
registerTrainer
public void registerTrainer(Distribution dist, DistributionTrainer trainer)
Description copied from interface:DistributionTrainerContextRegister a Distribution and an associated DistributionTrainer object.
In the registerWithTrainer method of a Distribution, it should associate itself with a trainer using this method.
- Specified by:
registerTrainerin interfaceDistributionTrainerContext- Parameters:
dist- the distribution to be registered.trainer- the distribution's trainer object to be registered.
-
getTrainer
public DistributionTrainer getTrainer(Distribution dist)
Description copied from interface:DistributionTrainerContextReturn the Distribution trainer object from the current context.- Specified by:
getTrainerin interfaceDistributionTrainerContext- Parameters:
dist- the Distribution whose trainer is required- Returns:
- the DistributionTrainer for the distribution
-
addCount
public void addCount(Distribution dist, Symbol sym, double times) throws IllegalSymbolException
Description copied from interface:DistributionTrainerContextRegisters that sym was counted in this state.
This method may be called multiple times with the same symbol. In this case, the times should be summed.
- Specified by:
addCountin interfaceDistributionTrainerContext- Parameters:
dist- the Distribution that the symbol was associated withsym- the Symbol seentimes- the number of times to add- Throws:
IllegalSymbolException- if sym is not recognised by dist
-
getCount
public double getCount(Distribution dist, Symbol sym) throws IllegalSymbolException
Description copied from interface:DistributionTrainerContextReturn the number of counts of a particular symbol which will be used to train the specified distribution.- Specified by:
getCountin interfaceDistributionTrainerContext- Parameters:
dist- the Distribution to return counts forsym- the symbol to get the count for- Returns:
- the number of counts
- Throws:
IllegalSymbolException- if the symbol is not accepted by the distribution
-
train
public void train() throws ChangeVetoException
Description copied from interface:DistributionTrainerContextTrains the Distribution, given a null model.
This will use the information collected with multiple addCount calls, and the null model to generate the new weights.
- Specified by:
trainin interfaceDistributionTrainerContext- Throws:
ChangeVetoException- if any of the distributions can't be trained
-
clearCounts
public void clearCounts()
Description copied from interface:DistributionTrainerContextClears all of the counts to zero.- Specified by:
clearCountsin interfaceDistributionTrainerContext
-
-