## org.biojava.bio.dp
Class SimpleModelTrainer

    java.lang.Object
      |
      +--org.biojava.bio.dist.SimpleDistributionTrainerContext
            |
            +--org.biojava.bio.dp.SimpleModelTrainer

public class SimpleModelTrainer
extends SimpleDistributionTrainerContext
implements ModelTrainer, java.io.Serializable

See Also:
  Serialized Form

Constructor Summary
`SimpleModelTrainer(MarkovModel model, Distribution nullModel, double nullModelWeight, double transCounts, double transCountWeight)` Create a model trainer for a particular model.

Method Summary
`void` `addTransitionCount(State from, State to, double count)` Adds some counts to the transition between two states.
`void` `clearCounts()` Clears all of the counts, ready for re-training.
`java.util.Set` `getAllTransitionTrainers()`
`TransitionTrainer` `getTrainerForModel(MarkovModel model)` Retrieve the TransitionTrainer associated with a model, or null if none is registered.
`void` `registerTrainerForModel(MarkovModel model, TransitionTrainer trainer)` Register a trainer as being for a model.
`void` `registerTrainerForTransition(State from, State to, TransitionTrainer trainer, State source, State destination)` Register a TransitionTrainer, a source and a destination state with a pair of states.
`void` `train()` Trains up the transitions in this model with the counts so far.
`java.util.Set` `trainersForTransition(State from, State to)` Retrieves a Set of TransitionTrainers associated with a transition between a pair of states.

Methods inherited from class org.biojava.bio.dist.SimpleDistributionTrainerContext
`addCount, clearDistributionCounts, getDistributionTrainer, getNullModel, getNullModelWeight, registerDistribution, registerDistributionTrainer, setNullModel, setNullModelWeight, trainDistributions`

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

Constructor Detail

### SimpleModelTrainer

    public SimpleModelTrainer(MarkovModel model,
                              Distribution nullModel,
                              double nullModelWeight,
                              double transCounts,
                              double transCountWeight)
                       throws BioException

  Create a model trainer for a particular model.
  Parameters:
    `model` - the MarkovModel to train
    `nullModel` - the null state model - possibly null
    `nullModelWeight` - how many times to add the null model
    `transCounts` - the counts to add to each transition
    `transCountWeight` - how many times to add them
  Throws:
    BioException - if for any reason the trainer could not be built

Method Detail

### addTransitionCount

    public void addTransitionCount(State from,
                                   State to,
                                   double count)
                            throws IllegalSymbolException,
                                   IllegalTransitionException

  Description copied from interface: ModelTrainer
  Adds some counts to the transition between two states.
  Specified by:
    addTransitionCount in interface ModelTrainer
  Tags copied from interface: ModelTrainer
  Parameters:
    `from` - the source of the transition
    `to` - the destination of the transition
    `counts` - how many counts to add
  Throws:
    IllegalSymbolException - if either from or to are not in the model
    IllegalTransitionException - if the model doesn't contain a transition between the states

### train

    public void train()
               throws IllegalSymbolException,
                      IllegalTransitionException

  Description copied from interface: ModelTrainer
  Trains up the transitions in this model with the counts so far.

  This method should not throw any exceptions. I am considering making this much tighter now that we have the vetoable mutator methods.

  Specified by:
    train in interface ModelTrainer
  Tags copied from interface: ModelTrainer
  Throws:
    IllegalSymbolException - if something went wrong with locating symbols in an emission spectrum or if a state couldn't be located
    IllegalTransitionException - if an attempt was made to train a transition that couldn't be located

### clearCounts

    public void clearCounts()

  Description copied from interface: ModelTrainer
  Clears all of the counts, ready for re-training.
  Specified by:
    clearCounts in interface ModelTrainer

### registerTrainerForTransition

    public void registerTrainerForTransition(State from,
                                             State to,
                                             TransitionTrainer trainer,
                                             State source,
                                             State destination)
                                      throws BioException

  Description copied from interface: ModelTrainer
  Register a TransitionTrainer, a source and a destination state with a pair of states.

  More than one TransitionTrainer and source, destination pairs may be associated with a pair of states, in which case counts will be added to each trainer and source, destination.

  The TransitionTrainer must have been added previously using registerTrainerForModel.

  Specified by:
    registerTrainerForTransition in interface ModelTrainer
  Tags copied from interface: ModelTrainer
  Parameters:
    `from` - the source state of the observed transition
    `to` - the destination state of the observed transition
    `trainer` - the TransitionTrainer to add to the list of trainers
    `source` - the source state for the trainer
    `destination` - the destination state for the trainer
  Throws:
    BioException - if the trainer is not yet registered
    NullPointerException - if any of the arguments are null

### trainersForTransition

    public java.util.Set trainersForTransition(State from,
                                               State to)

  Description copied from interface: ModelTrainer
  Retrieves a Set of TransitionTrainers associated with a transition between a pair of states.

  Do not change the fields of the TrainerTransition objects in the returned Set, and do not change the Set.

  Specified by:
    trainersForTransition in interface ModelTrainer
  Tags copied from interface: ModelTrainer
  Parameters:
    `from` - the source state
    `to` - the destination state
  Returns:
    a Set, possibly empty, of TrainerTransition objects

### getAllTransitionTrainers

    public java.util.Set getAllTransitionTrainers()

### getTrainerForModel

    public TransitionTrainer getTrainerForModel(MarkovModel model)

  Description copied from interface: ModelTrainer
  Retrieve the TransitionTrainer associated with a model, or null if none is registered.
  Specified by:
    getTrainerForModel in interface ModelTrainer

### registerTrainerForModel

    public void registerTrainerForModel(MarkovModel model,
                                        TransitionTrainer trainer)
                                 throws BioException

  Description copied from interface: ModelTrainer
  Register a trainer as being for a model.
  Specified by:
    registerTrainerForModel in interface ModelTrainer
  Tags copied from interface: ModelTrainer
  Parameters:
    `model` - the MarkovModel to train
    `trainer` - the trainer that will train the model
  Throws:
    BioException - if the model already has a trainer associated