pyemma.coordinates.transform.VAMPModel

class pyemma.coordinates.transform.VAMPModel(mean_0=None, mean_t=None, C00=None, Ctt=None, C0t=None, dim=None, epsilon=1e-06, scaling=None)
__init__(mean_0=None, mean_t=None, C00=None, Ctt=None, C0t=None, dim=None, epsilon=1e-06, scaling=None)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([mean_0, mean_t, C00, Ctt, C0t, …])

Initialize self.

dimension()

output dimension

expectation(observables, statistics[, …])

Compute future expectation of observable or covariance using the approximated Koopman operator.

get_model_params([deep])

Get parameters for this model.

load(file_name[, model_name])

Loads a previously saved PyEMMA object from disk.

save(file_name[, model_name, overwrite, …])

saves the current state of this object to given file and name.

score([test_model, score_method])

Compute the VAMP score for this model or the cross-validation score between self and a second model.

set_model_params(mean_0, mean_t, C00, Ctt, …)

update_model_params(**params)

Update given model parameter if they are set to specific values

Attributes

C00

C0t

Ctt

U

Tranformation matrix that represents the linear map from mean-free feature space to the space of left singular functions.

V

Tranformation matrix that represents the linear map from mean-free feature space to the space of right singular functions.

cumvar

cumulative kinetic variance

scaling

Scaling of projection.

singular_values

The singular values of the half-weighted Koopman matrix

U

Tranformation matrix that represents the linear map from mean-free feature space to the space of left singular functions.

V

Tranformation matrix that represents the linear map from mean-free feature space to the space of right singular functions.

cumvar

cumulative kinetic variance

dimension()

output dimension

expectation(observables, statistics, lag_multiple=1, observables_mean_free=False, statistics_mean_free=False)

Compute future expectation of observable or covariance using the approximated Koopman operator.

Parameters
  • observables (np.ndarray((input_dimension, n_observables))) – Coefficients that express one or multiple observables in the basis of the input features.

  • statistics (np.ndarray((input_dimension, n_statistics)), optional) – Coefficients that express one or multiple statistics in the basis of the input features. This parameter can be None. In that case, this method returns the future expectation value of the observable(s).

  • lag_multiple (int) – If > 1, extrapolate to a multiple of the estimator’s lag time by assuming Markovianity of the approximated Koopman operator.

  • observables_mean_free (bool, default=False) – If true, coefficients in observables refer to the input features with feature means removed. If false, coefficients in observables refer to the unmodified input features.

  • statistics_mean_free (bool, default=False) – If true, coefficients in statistics refer to the input features with feature means removed. If false, coefficients in statistics refer to the unmodified input features.

Notes

A “future expectation” of a observable g is the average of g computed over a time window that has the same total length as the input data from which the Koopman operator was estimated but is shifted by lag_multiple*tau time steps into the future (where tau is the lag time).

It is computed with the equation:

\[\mathbb{E}[g]_{\rho_{n}}=\mathbf{q}^{T}\mathbf{P}^{n-1}\mathbf{e}_{1}\]

where

\[P_{ij}=\sigma_{i}\langle\psi_{i},\phi_{j}\rangle_{\rho_{1}}\]

and

\[q_{i}=\langle g,\phi_{i}\rangle_{\rho_{1}}\]

and \(\mathbf{e}_{1}\) is the first canonical unit vector.

A model prediction of time-lagged covariances between the observable f and the statistic g at a lag-time of lag_multiple*tau is computed with the equation:

\[\mathrm{cov}[g,\,f;n\tau]=\mathbf{q}^{T}\mathbf{P}^{n-1}\boldsymbol{\Sigma}\mathbf{r}\]

where \(r_{i}=\langle\psi_{i},f\rangle_{\rho_{0}}\) and \(\boldsymbol{\Sigma}=\mathrm{diag(\boldsymbol{\sigma})}\) .

get_model_params(deep=True)

Get parameters for this model.

Parameters

deep (boolean, optional) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

params – Parameter names mapped to their values.

Return type

mapping of string to any

classmethod load(file_name, model_name='default')

Loads a previously saved PyEMMA object from disk.

Parameters
  • file_name (str or file like object (has to provide read method)) – The file like object tried to be read for a serialized object.

  • model_name (str, default='default') – if multiple models are contained in the file, these can be accessed by their name. Use pyemma.list_models() to get a representation of all stored models.

Returns

obj

Return type

the de-serialized object

save(file_name, model_name='default', overwrite=False, save_streaming_chain=False)

saves the current state of this object to given file and name.

Parameters
  • file_name (str) – path to desired output file

  • model_name (str, default='default') – creates a group named ‘model_name’ in the given file, which will contain all of the data. If the name already exists, and overwrite is False (default) will raise a RuntimeError.

  • overwrite (bool, default=False) – Should overwrite existing model names?

  • save_streaming_chain (boolean, default=False) – if True, the data_producer(s) of this object will also be saved in the given file.

Examples

>>> import pyemma, numpy as np
>>> from pyemma.util.contexts import named_temporary_file
>>> m = pyemma.msm.MSM(P=np.array([[0.1, 0.9], [0.9, 0.1]]))
>>> with named_temporary_file() as file: # doctest: +SKIP
...    m.save(file, 'simple') # doctest: +SKIP
...    inst_restored = pyemma.load(file, 'simple') # doctest: +SKIP
>>> np.testing.assert_equal(m.P, inst_restored.P) # doctest: +SKIP
scaling

Scaling of projection. Can be None or ‘kinetic map’, ‘km’

score(test_model=None, score_method='VAMP2')

Compute the VAMP score for this model or the cross-validation score between self and a second model.

Parameters
  • test_model (VAMPModel, optional, default=None) –

    If test_model is not None, this method computes the cross-validation score between self and test_model. It is assumed that self was estimated from the “training” data and test_model was estimated from the “test” data. The score is computed for one realization of self and test_model. Estimation of the average cross-validation score and partitioning of data into test and training part is not performed by this method.

    If test_model is None, this method computes the VAMP score for the model contained in self.

  • score_method (str, optional, default='VAMP2') –

    Available scores are based on the variational approach for Markov processes 1:

    • ’VAMP1’ Sum of singular values of the half-weighted Koopman matrix 1 .

      If the model is reversible, this is equal to the sum of Koopman matrix eigenvalues, also called Rayleigh quotient 1.

    • ’VAMP2’ Sum of squared singular values of the half-weighted Koopman matrix 1 .

      If the model is reversible, this is equal to the kinetic variance 2 .

    • ’VAMPE’ Approximation error of the estimated Koopman operator with respect to

      the true Koopman operator up to an additive constant 1 .

Returns

score – If test_model is not None, returns the cross-validation VAMP score between self and test_model. Otherwise return the selected VAMP-score of self.

Return type

float

References

1(1,2,3,4,5)

Wu, H. and Noe, F. 2017. Variational approach for learning Markov processes from time series data. arXiv:1707.04659v1

2

Noe, F. and Clementi, C. 2015. Kinetic distance and kinetic maps from molecular dynamics simulation. J. Chem. Theory. Comput. doi:10.1021/acs.jctc.5b00553

singular_values

The singular values of the half-weighted Koopman matrix

update_model_params(**params)

Update given model parameter if they are set to specific values