MarkovChain¶
- class pycave.bayes.MarkovChain(num_states=None, *, symmetric=False, batch_size=None, trainer_params=None)[source]¶
Bases:
ConfigurableBaseEstimator
[MarkovChainModel
]Probabilistic model for observed state transitions. The Markov chain is similar to the hidden Markov model, only that the hidden states are known. More information on the Markov chain is available on Wikipedia.
See also
PyTorch module for a Markov chain.
Configuration class for a Markov chain model.
- Parameters:
num_states (int | None) -- The number of states that the Markov chain has. If not provided, it will be derived automatically when calling
fit()
. Note that this requires a pass through the data. Consider setting this option explicitly if you're fitting a lot of data.symmetric (bool) -- Whether the transitions between states should be considered symmetric.
batch_size (int | None) -- The batch size to use when fitting the model. If not provided, the full data will be used as a single batch. Set this if the full data does not fit into memory.
num_workers -- The number of workers to use for loading the data. Only used if a PyTorch dataset is passed to
fit()
or related methods.trainer_params (dict[str, Any] | None) --
Initialization parameters to use when initializing a PyTorch Lightning trainer. By default, it disables various stdout logs unless PyCave is configured to do verbose logging. Checkpointing and logging are disabled regardless of the log level. This estimator further enforces the following parameters:
max_epochs=1
Methods
Fits the Markov chain on the provided data and returns the fitted estimator. |
|
Samples state sequences from the fitted Markov chain. |
|
Computes the average negative log-likelihood (NLL) of observing the provided sequences. |
|
Computes the average negative log-likelihood (NLL) of observing the provided sequences. |
Inherited Methods
Clones the estimator without copying any fitted attributes. |
|
Returns the estimator's parameters as passed to the initializer. |
|
Loads the estimator and (if available) the fitted model. |
|
Loads the fitted attributes that are stored at the fitted path. |
|
Initializes this estimator by loading its parameters. |
|
Saves the estimator to the provided directory. |
|
Saves the fitted attributes of this estimator. |
|
Saves the parameters of this estimator. |
|
Sets the provided values on the estimator. |
|
Returns the trainer as configured by the estimator. |
Attributes
|
Returns the list of fitted attributes that ought to be saved and loaded. |
|
The fitted PyTorch module with all estimated parameters. |