class BayesianHMMPosterior

class deeptime.markov.hmm.BayesianHMMPosterior(prior: Optional[HiddenMarkovModel] = None, samples: Optional[List[HiddenMarkovModel]] = ())

Bayesian Hidden Markov model with samples of posterior and prior.

Parameters:

See also

BayesianHMM

Attributes

hidden_state_trajectories_samples

Hidden state trajectories of sampled HMMs.

lagtime

Lagtime of the models.

prior

The prior model.

samples

The sampled models.

Methods

ck_test(models[, include_lag0, err_est, ...])

Performs a Chapman Kolmogorov test.

copy()

Makes a deep copy of this model.

evaluate_samples(quantity[, delimiter])

Obtains a quantity (like an attribute or result of a method or a property) from each of the samples.

gather_stats(quantity[, store_samples, ...])

Obtain statistics about a sampled quantity.

get_params([deep])

Get the parameters.

set_params(**params)

Set the parameters of this estimator.

submodel([states, obs])

Creates a submodel from this model restricted to a selection of observable and hidden states.

submodel_largest([directed, ...])

Creates a submodel from the largest connected set.

submodel_populous([directed, ...])

Creates a submodel from the most populated connected set.

timescales([k])

Relaxation timescales corresponding to the eigenvalues.

ck_test(models, include_lag0=True, err_est=False, progress=None, **kw)

Performs a Chapman Kolmogorov test. See MarkovStateModel.ck_test for more details

copy() Model

Makes a deep copy of this model.

Returns:

A new copy of this model.

Return type:

copy

evaluate_samples(quantity, delimiter='/', *args, **kwargs)

Obtains a quantity (like an attribute or result of a method or a property) from each of the samples. Returns as list.

Parameters:
  • quantity (str) – The quantity. Can be also deeper in the instance hierarchy, indicated by the delimiter.

  • delimiter (str, default='/') – The delimiter.

  • *args – Arguments passed to the evaluation point of the quantity.

  • **kwargs – Keyword arguments passed to the evaluation point of the quantity.

Returns:

result – A list of the quantity evaluated on each of the samples. If can be converted to float ndarray then ndarray.

Return type:

list of any or ndarray

gather_stats(quantity, store_samples=False, delimiter='/', confidence=0.95, *args, **kwargs)

Obtain statistics about a sampled quantity. Can also be a chained call, separated by the delimiter.

Parameters:
  • quantity (str) – name of attribute, which will be evaluated on samples

  • store_samples (bool, optional, default=False) – whether to store the samples (array).

  • delimiter (str, optional, default='/') – separator to call members of members

  • confidence (float, optional, default=0.95) – Size of the confidence intervals.

  • *args – pass-through

  • **kwargs – pass-through

Returns:

statistics – The statistics

Return type:

deeptime.util.QuantityStatistics

get_params(deep=False)

Get the parameters.

Returns:

params – Parameter names mapped to their values.

Return type:

mapping of string to any

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

object

submodel(states=None, obs=None)

Creates a submodel from this model restricted to a selection of observable and hidden states.

Parameters:
  • states (ndarray or None, optional, default=None) – The hidden states to restrict to. If None there is no restriction.

  • obs (ndarray or None, optional, default=None) – The observable states to restrict to. If None there is no restriction. Only makes sense with DiscreteOutputModel.

Returns:

submodel – The submodel.

Return type:

BayesianHMMPosterior

submodel_largest(directed=True, connectivity_threshold='1/n', observe_nonempty=True, dtrajs=None)

Creates a submodel from the largest connected set.

Parameters:
  • directed (bool, optional, default=True) – Whether the connectivity graph on the count matrix is interpreted as directed.

  • connectivity_threshold (float or '1/n', optional, default='1/n'.) – Connectivity threshold. counts that are below the specified value are disregarded when finding connected sets. In case of ‘1/n’, the threshold gets resolved to \(1 / n\_states\_full\).

  • observe_nonempty (bool, optional, default=True) – Whether to restrict to observable states which are observed in provided dtrajs. If True, dtrajs must not be None.

  • dtrajs (array_like or list of array_like, optional, default=None) – Time series on which is evaluated whether observable states in the model were actually observed.

Returns:

submodel – The submodel.

Return type:

BayesianHMMPosterior

submodel_populous(directed=True, connectivity_threshold='1/n', observe_nonempty=True, dtrajs=None)

Creates a submodel from the most populated connected set.

Parameters:
  • directed (bool, optional, default=True) – Whether the connectivity graph on the count matrix is interpreted as directed.

  • connectivity_threshold (float or '1/n', optional, default='1/n'.) – Connectivity threshold. counts that are below the specified value are disregarded when finding connected sets. In case of ‘1/n’, the threshold gets resolved to \(1 / n\_states\_full\).

  • observe_nonempty (bool, optional, default=True) – Whether to restrict to observable states which are observed in provided dtrajs. If True, dtrajs must not be None.

  • dtrajs (array_like or list of array_like, optional, default=None) – Time series on which is evaluated whether observable states in the model were actually observed and which states were the most populated.

Returns:

submodel – The submodel.

Return type:

BayesianHMMPosterior

timescales(k=None)

Relaxation timescales corresponding to the eigenvalues.

Parameters:

k (int, optional, default=None) – The number of timescales (excluding the stationary process).

Returns:

timescales – Timescales of the prior and timescales of the samples.

Return type:

tuple(iterable, iterable)

property hidden_state_trajectories_samples

Hidden state trajectories of sampled HMMs. Available if the estimator was configured to save them, see BayesianHMM.store_hidden.

property lagtime

Lagtime of the models.

property prior: HiddenMarkovModel

The prior model.

property samples: Optional[List[HiddenMarkovModel]]

The sampled models.