Class SimpleDistributionTrainerContext
- All Implemented Interfaces:
Serializable
,DistributionTrainerContext
- Direct Known Subclasses:
SimpleModelTrainer
- Since:
- 1.0
- Author:
- Matthew Pocock
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new context with no initial distributions or trainers. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCount
(Distribution dist, Symbol sym, double times) Registers that sym was counted in this state.void
Clears all of the counts to zero.double
getCount
(Distribution dist, Symbol sym) Return the number of counts of a particular symbol which will be used to train the specified distribution.double
Return the number of pseudocounts added to the distribution when training.getTrainer
(Distribution dist) Return the Distribution trainer object from the current context.void
Register a distribution object with this context.void
registerTrainer
(Distribution dist, DistributionTrainer trainer) Register a Distribution and an associated DistributionTrainer object.void
setNullModelWeight
(double nullModelWeight) Set the number of pseudocounts to add when training the distribution.void
train()
Trains the Distribution, given a null model.
-
Constructor Details
-
SimpleDistributionTrainerContext
public SimpleDistributionTrainerContext()Create a new context with no initial distributions or trainers.
-
-
Method Details
-
getNullModelWeight
Description copied from interface:DistributionTrainerContext
Return the number of pseudocounts added to the distribution when training.- Specified by:
getNullModelWeight
in interfaceDistributionTrainerContext
- Returns:
- the null model weight
-
setNullModelWeight
Description copied from interface:DistributionTrainerContext
Set 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:
setNullModelWeight
in interfaceDistributionTrainerContext
- Parameters:
nullModelWeight
- the new null model weight
-
registerDistribution
Description copied from interface:DistributionTrainerContext
Register 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:
registerDistribution
in interfaceDistributionTrainerContext
- Parameters:
dist
- the Distribution to register
-
registerTrainer
Description copied from interface:DistributionTrainerContext
Register 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:
registerTrainer
in interfaceDistributionTrainerContext
- Parameters:
dist
- the distribution to be registered.trainer
- the distribution's trainer object to be registered.
-
getTrainer
Description copied from interface:DistributionTrainerContext
Return the Distribution trainer object from the current context.- Specified by:
getTrainer
in interfaceDistributionTrainerContext
- Parameters:
dist
- the Distribution whose trainer is required- Returns:
- the DistributionTrainer for the distribution
-
addCount
Description copied from interface:DistributionTrainerContext
Registers 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:
addCount
in 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
Description copied from interface:DistributionTrainerContext
Return the number of counts of a particular symbol which will be used to train the specified distribution.- Specified by:
getCount
in 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
Description copied from interface:DistributionTrainerContext
Trains 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:
train
in interfaceDistributionTrainerContext
- Throws:
ChangeVetoException
- if any of the distributions can't be trained
-
clearCounts
Description copied from interface:DistributionTrainerContext
Clears all of the counts to zero.- Specified by:
clearCounts
in interfaceDistributionTrainerContext
-