pyemma.msm.MaximumLikelihoodHMSM¶
-
class
pyemma.msm.
MaximumLikelihoodHMSM
(*args, **kwargs)¶ Maximum likelihood estimator for a Hidden MSM given a MSM
-
__init__
(nstates=2, lag=1, stride=1, msm_init='largest-strong', reversible=True, stationary=False, connectivity=None, mincount_connectivity='1/n', observe_nonempty=True, separate=None, dt_traj='1 step', accuracy=0.001, maxit=1000)¶ Maximum likelihood estimator for a Hidden MSM given a MSM
- Parameters
nstates (int, optional, default=2) – number of hidden states
lag (int, optional, default=1) – lagtime to estimate the HMSM at
stride (str or int, default=1) –
stride between two lagged trajectories extracted from the input trajectories. Given trajectory s[t], stride and lag will result in trajectories
s[0], s[lag], s[2 lag], … s[stride], s[stride + lag], s[stride + 2 lag], …
Setting stride = 1 will result in using all data (useful for maximum likelihood estimator), while a Bayesian estimator requires a longer stride in order to have statistically uncorrelated trajectories. Setting stride = ‘effective’ uses the largest neglected timescale as an estimate for the correlation time and sets the stride accordingly
msm_init (str or
MSM
) –MSM object to initialize the estimation, or one of following keywords:
- ’largest-strong’ or None (default)Estimate MSM on the largest
strongly connected set and use spectral clustering to generate an initial HMM
- ’all’Estimate MSM(s) on the full state space to initialize the
HMM. This estimate maybe weakly connected or disconnected.
reversible (bool, optional, default = True) – If true compute reversible MSM, else non-reversible MSM
stationary (bool, optional, default=False) – If True, the initial distribution of hidden states is self-consistently computed as the stationary distribution of the transition matrix. If False, it will be estimated from the starting states. Only set this to true if you’re sure that the observation trajectories are initiated from a global equilibrium distribution.
connectivity (str, optional, default = None) –
Defines if the resulting HMM will be defined on all hidden states or on a connected subset. Connectivity is defined by counting only transitions with at least mincount_connectivity counts. If a subset of states is used, all estimated quantities (transition matrix, stationary distribution, etc) are only defined on this subset and are correspondingly smaller than nstates. Following modes are available:
None or ‘all’ : The active set is the full set of states. Estimation is done on all weakly connected subsets separately. The resulting transition matrix may be disconnected.
’largest’ : The active set is the largest reversibly connected set.
’populous’ : The active set is the reversibly connected set with most counts.
mincount_connectivity (float or '1/n') – minimum number of counts to consider a connection between two states. Counts lower than that will count zero in the connectivity check and may thus separate the resulting transition matrix. The default evaluates to 1/nstates.
separate (None or iterable of int) – Force the given set of observed states to stay in a separate hidden state. The remaining nstates-1 states will be assigned by a metastable decomposition.
observe_nonempty (bool) – If True, will restricted the observed states to the states that have at least one observation in the lagged input trajectories. If an initial MSM is given, this option is ignored and the observed subset is always identical to the active set of that MSM.
dt_traj (str, optional, default='1 step') –
Description of the physical time corresponding to the trajectory time step. May be used by analysis algorithms such as plotting tools to pretty-print the axes. By default ‘1 step’, i.e. there is no physical time unit. Specify by a number, whitespace and unit. Permitted units are (* is an arbitrary string):
’fs’, ‘femtosecond*’’ps’, ‘picosecond*’’ns’, ‘nanosecond*’’us’, ‘microsecond*’’ms’, ‘millisecond*’’s’, ‘second*’accuracy (float, optional, default = 1e-3) – convergence threshold for EM iteration. When two the likelihood does not increase by more than accuracy, the iteration is stopped successfully.
maxit (int, optional, default = 1000) – stopping criterion for EM iteration. When so many iterations are performed without reaching the requested accuracy, the iteration is stopped without convergence (a warning is given)
Methods
_Loggable__create_logger
()_SerializableMixIn__interpolate
(state, klass)__delattr__
(name, /)Implement delattr(self, name).
__dir__
()Default dir() implementation.
__eq__
(other)Return self==value.
__format__
(format_spec, /)Default object formatter.
__ge__
(value, /)Return self>=value.
__getattribute__
(name, /)Return getattr(self, name).
__getstate__
()__gt__
(value, /)Return self>value.
__init__
([nstates, lag, stride, msm_init, …])Maximum likelihood estimator for a Hidden MSM given a MSM
__init_subclass__
(*args, **kwargs)This method is called when a class is subclassed.
__le__
(value, /)Return self<=value.
__lt__
(value, /)Return self<value.
__my_getstate__
()__my_setstate__
(state)__ne__
(value, /)Return self!=value.
__new__
(cls, *args, **kwargs)Create and return a new object.
__reduce__
()Helper for pickle.
__reduce_ex__
(protocol, /)Helper for pickle.
__repr__
()Return repr(self).
__setattr__
(name, value, /)Implement setattr(self, name, value).
__setstate__
(state)__sizeof__
()Size of object in memory, in bytes.
__str__
()Return str(self).
__subclasshook__
Abstract classes can override this to customize issubclass().
_assert_in_active
(A)Checks if set A is within the active set
_assert_metastable
()Tests if pcca object is available, or else raises a ValueError.
_check_estimated
()_cleanup_logger
(logger_id, logger_name)_committor_backward
(P, A, B[, mu])_committor_forward
(P, A, B)_compute_eigendecomposition
(neig)Conducts the eigenvalue decomposition and stores k eigenvalues, left and right eigenvectors
_compute_eigenvalues
(neig)Conducts the eigenvalue decomposition and stores k eigenvalues, left and right eigenvectors
_ensure_eigendecomposition
([neig])Ensures that eigendecomposition has been performed with at least neig eigenpairs
_ensure_eigenvalues
([neig])Ensures that at least neig eigenvalues have been computed
_estimate
(dtrajs)_get_classes_to_inspect
()gets classes self derives from which 1.
_get_interpolation_map
(cls)_get_model_param_names
()Get parameter names for the model
_get_param_names
()Get parameter names for the estimator
_get_private_field
(cls, name[, default])_get_serialize_fields
(cls)_get_state_of_serializeable_fields
(klass, state):return a dictionary {k:v} for k in self.serialize_fields and v=getattr(self, k)
_get_version
(cls[, require])_get_version_for_class_from_state
(state, klass)retrieves the version of the current klass from the state mapping from old locations to new ones.
_logger_is_active
(level)@param level: int log level (debug=10, info=20, warn=30, error=40, critical=50)
_mfpt
(P, A, B[, mu])_set_state_from_serializeable_fields_and_state
(…)set only fields from state, which are present in klass.__serialize_fields
cktest
([mlags, conf, err_est, n_jobs, …])Conducts a Chapman-Kolmogorow test.
committor_backward
(A, B)Backward committor from set A to set B
committor_forward
(A, B)Forward committor (also known as p_fold or splitting probability) from set A to set B
correlation
(a[, b, maxtime, k, ncv])Time-correlation for equilibrium experiment.
eigenvalues
([k])Compute the transition matrix eigenvalues
eigenvectors_left
([k])Compute the left transition matrix eigenvectors
eigenvectors_right
([k])Compute the right transition matrix eigenvectors
estimate
(X, **params)Estimates the model given the data X
expectation
(a)Equilibrium expectation value of a given observable.
fingerprint_correlation
(a[, b, k, ncv])Dynamical fingerprint for equilibrium time-correlation experiment.
fingerprint_relaxation
(p0, a[, k, ncv])Dynamical fingerprint for perturbation/relaxation experiment.
fit
(X[, y])Estimates parameters - for compatibility with sklearn.
get_model_params
([deep])Get parameters for this model.
get_params
([deep])Get parameters for this estimator.
load
(file_name[, model_name])Loads a previously saved PyEMMA object from disk.
mfpt
(A, B)Mean first passage times from set A to set B, in units of the input trajectory time step
pcca
(m)Runs PCCA++ [1]_ to compute a metastable decomposition of MSM states
propagate
(p0, k)Propagates the initial distribution p0 k times
relaxation
(p0, a[, maxtime, k, ncv])Simulates a perturbation-relaxation experiment.
sample_by_observation_probabilities
(nsample)Generates samples according to the current observation probability distribution
save
(file_name[, model_name, overwrite, …])saves the current state of this object to given file and name.
set_model_params
([P, pobs, pi, reversible, …])- param P
coarse-grained or hidden transition matrix
set_params
(**params)Set the parameters of this estimator.
simulate
(N[, start, stop, dt])Generates a realization of the Hidden Markov Model
submodel
([states, obs, …])Returns a HMM with restricted state space
submodel_disconnect
([mincount_connectivity])Disconnects sets of hidden states that are barely connected
submodel_largest
([strong, mincount_connectivity])Returns the largest connected sub-HMM (convenience function)
submodel_populous
([strong, …])Returns the most populous connected sub-HMM (convenience function)
timescales
([k])The relaxation timescales corresponding to the eigenvalues
trajectory_weights
()Uses the HMSM to assign a probability weight to each trajectory frame.
transition_matrix_obs
([k])Computes the transition matrix between observed states
update_model_params
(**params)Update given model parameter if they are set to specific values
Attributes
P
The transition matrix on the active set.
_Estimator__serialize_fields
_HMSM__serialize_version
_Loggable__ids
_Loggable__refs
_MSM__serialize_fields
_MSM__serialize_version
_MaximumLikelihoodHMSM__serialize_fields
_MaximumLikelihoodHMSM__serialize_version
_SerializableMixIn__serialize_fields
_SerializableMixIn__serialize_modifications_map
_SerializableMixIn__serialize_version
__dict__
__doc__
__hash__
__module__
__weakref__
list of weak references to the object (if defined)
_estimated
_loglevel_CRITICAL
_loglevel_DEBUG
_loglevel_ERROR
_loglevel_INFO
_loglevel_WARN
_save_data_producer
active_set
The active set of hidden states on which all hidden state computations are done
discrete_trajectories_full
A list of integer arrays with the original trajectories.
discrete_trajectories_lagged
Transformed original trajectories that are used as an input into the HMM estimation
discrete_trajectories_obs
A list of integer arrays with the discrete trajectories mapped to the observation mode used.
dt_model
Description of the physical time corresponding to the lag.
dt_traj
dtrajs_full
A list of integer arrays with the original trajectories.
dtrajs_lagged
Transformed original trajectories that are used as an input into the HMM estimation
dtrajs_obs
A list of integer arrays with the discrete trajectories mapped to the observation mode used.
eigenvectors_left_obs
eigenvectors_right_obs
is_reversible
Returns whether the MSM is reversible
is_sparse
Returns whether the MSM is sparse
lagtime
The lag time in steps
lifetimes
Lifetimes of states of the hidden transition matrix
logger
The logger for this class instance
metastable_assignments
Computes the assignment to metastable sets for observable states
metastable_distributions
Returns the output probability distributions. Identical to
metastable_memberships
Computes the memberships of observable states to metastable sets by
metastable_sets
Computes the metastable sets of observable states within each
model
The model estimated by this Estimator
msm_init
n_metastable
Number of states chosen for PCCA++ computation.
name
The name of this instance
neig
number of eigenvalues to compute.
nstates
Number of active states on which all computations and estimations are done
nstates_obs
Number of states in discrete trajectories
observable_set
The active set of states on which all computations and estimations will be done
observable_state_indexes
Ensures that the observable states are indexed and returns the indices
observation_probabilities
returns the output probability matrix
pi
The stationary distribution on the MSM states
reversible
Returns whether the MSM is reversible
sparse
Returns whether the MSM is sparse
stationary_distribution
The stationary distribution on the MSM states
stationary_distribution_obs
timestep_model
Physical time corresponding to one transition matrix step, e.g.
transition_matrix
The transition matrix on the active set.
-