pyemma.msm.BayesianMSM¶
-
class
pyemma.msm.BayesianMSM(*args, **kwargs)¶ Bayesian Markov state model estimator
-
__init__(lag=1, nsamples=100, nsteps=None, reversible=True, statdist_constraint=None, count_mode='effective', sparse=False, connectivity='largest', dt_traj='1 step', conf=0.95, show_progress=True, mincount_connectivity='1/n', core_set=None, milestoning_method='last_core')¶ Bayesian estimator for MSMs given discrete trajectory statistics
- Parameters
lag (int, optional, default=1) – lagtime to estimate the HMSM at
nsamples (int, optional, default=100) – number of sampled transition matrices used
nsteps (int, optional, default=None) – number of Gibbs sampling steps for each transition matrix used. If None, nstep will be determined automatically
reversible (bool, optional, default = True) – If true compute reversible MSM, else non-reversible MSM
statdist_constraint ((M,) ndarray optional) – Stationary vector on the full set of states. Assign zero stationary probabilities to states for which the stationary vector is unknown. Estimation will be made such that the resulting ensemble of transition matrices is defined on the intersection of the states with positive stationary vector and the largest connected set (undirected).
count_mode (str, optional, default='effective') –
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 .. math:: (0 rightarray tau), (1 rightarray tau+1), …, (T-tau-1 rightarray 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 .. math:: (0 rightarray tau), (tau rightarray 2 tau), …, (((T/tau)-1) tau rightarray 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 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*’conf (float, optional, default=0.95) – Confidence interval. By default one-sigma (68.3%) is used. Use 95.4% for two sigma or 99.7% for three sigma.
show_progress (bool, default=True) – Show progressbars for calculation?
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
- 1(1,2,3,4)
Trendelkamp-Schroer, B., H. Wu, F. Paul and F. Noe: Estimation and uncertainty of reversible Markov models. J. Chem. Phys. (in review) Preprint: http://arxiv.org/abs/1507.05990
Methods
_Loggable__create_logger()_ProgressReporterMixin__check_stage_registered(stage)_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, nsamples, nsteps, …])Bayesian 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()_check_samples_available()_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.
_progress_context([stage])- param stage
_progress_force_finish([stage, description])forcefully finish the progress for given stage
_progress_register(amount_of_work[, …])Registers a progress which can be reported/displayed via a progress bar.
_progress_set_description(stage, description)set description of an already existing progress
_progress_update(numerator_increment[, …])Updates the progress.
_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, **kw)- 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.
sample_conf(f, *args, **kwargs)Sample confidence interval of numerical method f over all samples
sample_f(f, *args, **kwargs)Evaluated method f for all samples
sample_mean(f, *args, **kwargs)Sample mean of numerical method f over all samples
sample_std(f, *args, **kwargs)Sample standard deviation of numerical method f over all samples
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([samples, conf, P, pi, …])- param samples
sampled MSMs
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
PThe transition matrix on the active set.
_BayesianMSM__serialize_version_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_SampledMSM__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_pg_threshold_prog_rep_callbacks_prog_rep_descriptions_prog_rep_progressbars_progress_num_registered_progress_registered_stages_save_data_produceractive_count_fractionThe fraction of counts in the largest connected set.
active_setThe active set of states on which all computations and estimations will be done
active_state_fractionThe fraction of states in the largest connected set.
active_state_indexesEnsures that the connected states are indexed and returns the indices
connected_setsThe reversible connected sets of states, sorted by size (descending)
connectivityReturns the connectivity mode of the MSM
core_setlist of states which are defined to lie within the core set.
count_matrix_activeThe count matrix on the active set given the connectivity mode used.
count_matrix_fullThe count matrix on full set of discrete states, irrespective as to whether they are connected or not.
discrete_trajectories_activeA list of integer arrays with the discrete trajectories mapped to the connectivity mode used.
discrete_trajectories_fullA list of integer arrays with the original (unmapped) discrete trajectories:
discrete_trajectories_unmodifiedA list of integer arrays with the original and not modified discrete trajectories.
dt_modelDescription of the physical time corresponding to the lag.
dt_trajdtrajs_activeA list of integer arrays with the discrete trajectories mapped to the connectivity mode used.
dtrajs_fullA list of integer arrays with the original (unmapped) discrete trajectories:
dtrajs_milestone_counting_offsetsOffsets for milestone counted trajectories for each input discrete trajectory.
dtrajs_unmodifiedA list of integer arrays with the original and not modified discrete trajectories.
effective_count_matrixStatistically uncorrelated transition counts within the active set of states
is_reversibleReturns whether the MSM is reversible
is_sparseReturns whether the MSM is sparse
lagThe lag time at which the Markov model was estimated
lagtimeThe lag time at which the Markov model was estimated
largest_connected_setThe largest reversible connected set of states
loggerThe logger for this class instance
metastable_assignmentsAssignment of states to metastable sets using PCCA++
metastable_distributionsProbability of metastable states to visit an MSM state by PCCA++
metastable_membershipsProbabilities of MSM states to belong to a metastable state by PCCA++
metastable_setsMetastable sets using PCCA++
modelThe model estimated by this Estimator
n_jobsReturns number of jobs/threads to use during assignment of data.
n_metastableNumber of states chosen for PCCA++ computation.
nameThe name of this instance
neignumber of eigenvalues to compute.
nstatesNumber of active states on which all computations and estimations are done
nstates_fullNumber of states in discrete trajectories
piThe stationary distribution on the MSM states
reversibleReturns whether the MSM is reversible
samplesshow_progresswhether to show the progress of heavy calculations on this object.
sparseReturns whether the MSM is sparse
stationary_distributionThe stationary distribution on the MSM states
timestep_modelPhysical time corresponding to one transition matrix step, e.g.
transition_matrixThe transition matrix on the active set.
-