pyemma.msm.MaximumLikelihoodMSM¶
-
class
pyemma.msm.
MaximumLikelihoodMSM
(*args, **kwargs)¶ Maximum likelihood estimator for MSMs given discrete trajectory statistics
-
__init__
(lag=1, reversible=True, statdist_constraint=None, count_mode='sliding', sparse=False, connectivity='largest', dt_traj='1 step', maxiter=1000000, maxerr=1e-08, score_method='VAMP2', score_k=10, mincount_connectivity='1/n', core_set=None, milestoning_method='last_core')¶ Maximum likelihood estimator for MSMs given discrete trajectory statistics
- Parameters
lag (int) – lag time at which transitions are counted and the transition matrix is estimated.
reversible (bool, optional, default = True) – If true compute reversible MSM, else non-reversible MSM
statdist ((M,) ndarray, optional) – Stationary vector on the full set of states. Estimation will be made such the the resulting transition matrix has this distribution as an equilibrium distribution. Set probabilities to zero if these states should be excluded from the analysis.
count_mode (str, optional, default='sliding') –
mode to obtain count matrices from discrete trajectories. Should be one of:
’sliding’ : A trajectory of length T will have \(T-tau\) counts at time indexes
\[(0 \rightarrow \tau), (1 \rightarrow \tau+1), ..., (T-\tau-1 \rightarrow T-1)\]’effective’ : Uses an estimate of the transition counts that are statistically uncorrelated. Recommended when used with a Bayesian MSM.
’sample’ : A trajectory of length T will have \(T/tau\) counts at time indexes
\[(0 \rightarrow \tau), (\tau \rightarrow 2 \tau), ..., (((T/tau)-1) \tau \rightarrow T)\]
sparse (bool, optional, default = False) – If true compute count matrix, transition matrix and all derived quantities using sparse matrix algebra. In this case python sparse matrices will be returned by the corresponding functions instead of numpy arrays. This behavior is suggested for very large numbers of states (e.g. > 4000) because it is likely to be much more efficient.
connectivity (str, optional, default = 'largest') –
Connectivity mode. Three methods are intended (currently only ‘largest’ is implemented)
’largest’ : The active set is the largest reversibly connected set. All estimation will be done on this subset and all quantities (transition matrix, stationary distribution, etc) are only defined on this subset and are correspondingly smaller than the full set of states
’all’ : The active set is the full set of states. Estimation will be conducted on each reversibly connected set separately. That means the transition matrix will decompose into disconnected submatrices, the stationary vector is only defined within subsets, etc. Currently not implemented.
’none’ : The active set is the full set of states. Estimation will be conducted on the full set of states without ensuring connectivity. This only permits nonreversible estimation. Currently not implemented.
dt_traj (str, optional, default='1 step') –
Description of the physical time of the input trajectories. 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*’maxiter (int, optioanl, default = 1000000) – Optional parameter with reversible = True. maximum number of iterations before the transition matrix estimation method exits
maxerr (float, optional, default = 1e-8) – Optional parameter with reversible = True. convergence tolerance for transition matrix estimation. This specifies the maximum change of the Euclidean norm of relative stationary probabilities (\(x_i = \sum_k x_{ik}\)). The relative stationary probability changes \(e_i = (x_i^{(1)} - x_i^{(2)})/(x_i^{(1)} + x_i^{(2)})\) are used in order to track changes in small probabilities. The Euclidean norm of the change vector, \(|e_i|_2\), is compared to maxerr.
score_method (str, optional, default='VAMP2') –
Score to be used with score function. Available are:
score_k (int or None) – The maximum number of eigenvalues or singular values used in the score. If set to None, all available eigenvalues will be used.
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.
core_set (None (default) or array like, dtype=int) – Definition of core set for milestoning MSMs. If set to None, replaces state -1 (if found in discrete trajectories) and performs milestone counting. No effect for Voronoi-discretized trajectories (default). If a list or np.ndarray is supplied, discrete trajectories will be assigned accordingly.
milestoning_method (str) – Method to use for counting transitions in trajectories with unassigned frames. Currently available: | ‘last_core’, assigns unassigned frames to last visited core
References
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__
([lag, reversible, …])Maximum likelihood estimator for MSMs given discrete trajectory statistics
__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.
_blocksplit_dtrajs
(dtrajs, sliding)_check_estimated
()_check_is_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)Estimates the MSM
_get_classes_to_inspect
()gets classes self derives from which 1.
_get_dtraj_stats
(dtrajs)Compute raw trajectory counts
_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])_prepare_input_revpi
(C, pi)Max.
_set_state_from_serializeable_fields_and_state
(…)set only fields from state, which are present in klass.__serialize_fields
cktest
(nsets[, memberships, mlags, conf, …])Conducts a Chapman-Kolmogorow test.
coarse_grain
(ncoarse[, method])Returns a coarse-grained Markov model.
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
(dtrajs, **kwargs)- param dtrajs
discrete trajectories, stored as integer ndarrays (arbitrary size)
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.
generate_traj
(N[, start, stop, stride])Generates a synthetic discrete trajectory of length N and simulation time stride * lag time * N
get_model_params
([deep])Get parameters for this model.
get_params
([deep])Get parameters for this estimator.
hmm
(nhidden)Estimates a hidden Markov state model as described in 1
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_distributions
(distributions, nsample)Generates samples according to given probability distributions
sample_by_state
(nsample[, subset, replace])Generates samples of the connected states.
save
(file_name[, model_name, overwrite, …])saves the current state of this object to given file and name.
score
(dtrajs[, score_method, score_k])Scores the MSM using the dtrajs using the variational approach for Markov processes 1 [2]_
score_cv
(dtrajs[, n, score_method, score_k])Scores the MSM using the variational approach for Markov processes 1 [2]_ and crossvalidation [3]_ .
set_model_params
(P[, pi, reversible, …])Call to set all basic model parameters.
set_params
(**params)Set the parameters of this estimator.
simulate
(N[, start, stop, dt])Generates a realization of the Markov Model
timescales
([k])The relaxation timescales corresponding to the eigenvalues
trajectory_weights
()Uses the MSM to assign a probability weight to each trajectory frame.
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
_Loggable__ids
_Loggable__refs
_MSMEstimator__serialize_fields
_MSMEstimator__serialize_version
_MSM__serialize_fields
_MSM__serialize_version
_MaximumLikelihoodMSM__serialize_fields
_MaximumLikelihoodMSM__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_count_fraction
The fraction of counts in the largest connected set.
active_set
The active set of states on which all computations and estimations will be done
active_state_fraction
The fraction of states in the largest connected set.
active_state_indexes
Ensures that the connected states are indexed and returns the indices
connected_sets
The reversible connected sets of states, sorted by size (descending)
connectivity
Returns the connectivity mode of the MSM
core_set
list of states which are defined to lie within the core set.
count_matrix_active
The count matrix on the active set given the connectivity mode used.
count_matrix_full
The count matrix on full set of discrete states, irrespective as to whether they are connected or not.
discrete_trajectories_active
A list of integer arrays with the discrete trajectories mapped to the connectivity mode used.
discrete_trajectories_full
A list of integer arrays with the original (unmapped) discrete trajectories:
discrete_trajectories_unmodified
A list of integer arrays with the original and not modified discrete trajectories.
dt_model
Description of the physical time corresponding to the lag.
dt_traj
dtrajs_active
A list of integer arrays with the discrete trajectories mapped to the connectivity mode used.
dtrajs_full
A list of integer arrays with the original (unmapped) discrete trajectories:
dtrajs_milestone_counting_offsets
Offsets for milestone counted trajectories for each input discrete trajectory.
dtrajs_unmodified
A list of integer arrays with the original and not modified discrete trajectories.
effective_count_matrix
Statistically uncorrelated transition counts within the active set of states
is_reversible
Returns whether the MSM is reversible
is_sparse
Returns whether the MSM is sparse
lag
The lag time at which the Markov model was estimated
lagtime
The lag time at which the Markov model was estimated
largest_connected_set
The largest reversible connected set of states
logger
The logger for this class instance
metastable_assignments
Assignment of states to metastable sets using PCCA++
metastable_distributions
Probability of metastable states to visit an MSM state by PCCA++
metastable_memberships
Probabilities of MSM states to belong to a metastable state by PCCA++
metastable_sets
Metastable sets using PCCA++
model
The model estimated by this Estimator
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_full
Number of states in discrete trajectories
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
timestep_model
Physical time corresponding to one transition matrix step, e.g.
transition_matrix
The transition matrix on the active set.
-