本文整理汇总了Python中msmbuilder.msm.ContinuousTimeMSM类的典型用法代码示例。如果您正苦于以下问题:Python ContinuousTimeMSM类的具体用法?Python ContinuousTimeMSM怎么用?Python ContinuousTimeMSM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContinuousTimeMSM类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_uncertainties_backward
def test_uncertainties_backward():
n = 4
grid = NDGrid(n_bins_per_feature=n, min=-np.pi, max=np.pi)
seqs = grid.fit_transform(load_doublewell(random_state=0)['trajectories'])
model = ContinuousTimeMSM(verbose=False).fit(seqs)
sigma_ts = model.uncertainty_timescales()
sigma_lambda = model.uncertainty_eigenvalues()
sigma_pi = model.uncertainty_pi()
sigma_K = model.uncertainty_K()
yield lambda: np.testing.assert_array_almost_equal(
sigma_ts, [9.13698928, 0.12415533, 0.11713719])
yield lambda: np.testing.assert_array_almost_equal(
sigma_lambda, [1.76569687e-19, 7.14216858e-05, 3.31210649e-04, 3.55556718e-04])
yield lambda: np.testing.assert_array_almost_equal(
sigma_pi, [0.00741467, 0.00647945, 0.00626743, 0.00777847])
yield lambda: np.testing.assert_array_almost_equal(
sigma_K,
[[ 3.39252419e-04, 3.39246173e-04, 0.00000000e+00, 1.62090239e-06],
[ 3.52062861e-04, 3.73305510e-04, 1.24093936e-04, 0.00000000e+00],
[ 0.00000000e+00, 1.04708186e-04, 3.45098923e-04, 3.28820213e-04],
[ 1.25455972e-06, 0.00000000e+00, 2.90118599e-04, 2.90122944e-04]])
yield lambda: np.testing.assert_array_almost_equal(
model.ratemat_,
[[ -2.54439564e-02, 2.54431791e-02, 0.00000000e+00, 7.77248586e-07],
[ 2.64044208e-02,-2.97630373e-02, 3.35861646e-03, 0.00000000e+00],
[ 0.00000000e+00, 2.83988103e-03, -3.01998380e-02, 2.73599570e-02],
[ 6.01581838e-07, 0.00000000e+00, 2.41326592e-02, -2.41332608e-02]])
开发者ID:kyleabeauchamp,项目名称:msmbuilder,代码行数:29,代码来源:test_ratematrix.py
示例2: test_uncertainties_backward
def test_uncertainties_backward():
n = 4
grid = NDGrid(n_bins_per_feature=n, min=-np.pi, max=np.pi)
trajs = DoubleWell(random_state=0).get_cached().trajectories
seqs = grid.fit_transform(trajs)
model = ContinuousTimeMSM(verbose=False).fit(seqs)
sigma_ts = model.uncertainty_timescales()
sigma_lambda = model.uncertainty_eigenvalues()
sigma_pi = model.uncertainty_pi()
sigma_K = model.uncertainty_K()
yield lambda: np.testing.assert_array_almost_equal(
sigma_ts, [9.508936, 0.124428, 0.117638])
yield lambda: np.testing.assert_array_almost_equal(
sigma_lambda,
[1.76569687e-19, 7.14216858e-05, 3.31210649e-04, 3.55556718e-04])
yield lambda: np.testing.assert_array_almost_equal(
sigma_pi, [0.007496, 0.006564, 0.006348, 0.007863])
yield lambda: np.testing.assert_array_almost_equal(
sigma_K,
[[0.000339, 0.000339, 0., 0.],
[0.000352, 0.000372, 0.000122, 0.],
[0., 0.000103, 0.000344, 0.000329],
[0., 0., 0.00029, 0.00029]])
yield lambda: np.testing.assert_array_almost_equal(
model.ratemat_,
[[-0.0254, 0.0254, 0., 0.],
[0.02636, -0.029629, 0.003269, 0.],
[0., 0.002764, -0.030085, 0.027321],
[0., 0., 0.024098, -0.024098]])
开发者ID:Eigenstate,项目名称:msmbuilder,代码行数:31,代码来源:test_ratematrix.py
示例3: test_doublewell
def test_doublewell():
trjs = load_doublewell(random_state=0)['trajectories']
for n_states in [10, 50]:
clusterer = NDGrid(n_bins_per_feature=n_states)
assignments = clusterer.fit_transform(trjs)
for sliding_window in [True, False]:
model = ContinuousTimeMSM(lag_time=100, sliding_window=sliding_window)
model.fit(assignments)
assert model.optimizer_state_.success
开发者ID:rmcgibbo,项目名称:msmbuilder,代码行数:10,代码来源:test_ratematrix.py
示例4: test_fit_1
def test_fit_1():
# call fit, compare to MSM
sequence = [0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2]
model = ContinuousTimeMSM(verbose=False)
model.fit([sequence])
msm = MarkovStateModel(verbose=False)
msm.fit([sequence])
# they shouldn't be equal in general, but for this input they seem to be
np.testing.assert_array_almost_equal(model.transmat_, msm.transmat_)
开发者ID:synapticarbors,项目名称:msmbuilder-1,代码行数:11,代码来源:test_ratematrix.py
示例5: test_doublewell
def test_doublewell():
X = load_doublewell(random_state=0)['trajectories']
for i in range(3):
Y = NDGrid(n_bins_per_feature=10).fit_transform([X[i]])
model1 = MarkovStateModel(verbose=False).fit(Y)
model2 = ContinuousTimeMSM().fit(Y)
print('MSM uncertainty timescales:')
print(model1.uncertainty_timescales())
print('ContinuousTimeMSM uncertainty timescales:')
print(model2.uncertainty_timescales())
print()
开发者ID:evanfeinberg,项目名称:msmbuilder,代码行数:12,代码来源:test_msm_uncertainty.py
示例6: test_dump
def test_dump():
# gh-713
sequence = [0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2]
model = ContinuousTimeMSM(verbose=False)
model.fit([sequence])
d = tempfile.mkdtemp()
try:
utils.dump(model, '{}/cmodel'.format(d))
m2 = utils.load('{}/cmodel'.format(d))
np.testing.assert_array_almost_equal(model.transmat_, m2.transmat_)
finally:
shutil.rmtree(d)
开发者ID:Eigenstate,项目名称:msmbuilder,代码行数:13,代码来源:test_ratematrix.py
示例7: test_score_2
def test_score_2():
ds = MullerPotential(random_state=0).get_cached().trajectories
cluster = NDGrid(n_bins_per_feature=6,
min=[PARAMS['MIN_X'], PARAMS['MIN_Y']],
max=[PARAMS['MAX_X'], PARAMS['MAX_Y']])
assignments = cluster.fit_transform(ds)
test_indices = [5, 0, 4, 1, 2]
train_indices = [3, 6, 7, 8, 9]
model = ContinuousTimeMSM(lag_time=3, n_timescales=1)
model.fit([assignments[i] for i in train_indices])
test = model.score([assignments[i] for i in test_indices])
train = model.score_
print('train', train, 'test', test)
assert 1 <= test < 2
assert 1 <= train < 2
开发者ID:Eigenstate,项目名称:msmbuilder,代码行数:16,代码来源:test_ratematrix.py
示例8: test_hessian_2
def test_hessian_2():
n = 3
seqs = [
[1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2,
2, 1, 1, 1, 1, 2, 3, 3, 3, 3]]
model = ContinuousTimeMSM().fit(seqs)
print(model.timescales_)
print(model.uncertainty_timescales())
theta = model.theta_
C = model.countsmat_
print(C)
C_flat = (C + C.T)[np.triu_indices_from(C, k=1)]
print(C_flat)
print('theta', theta, '\n')
inds = np.where(theta != 0)[0]
hessian1 = _ratematrix.hessian(theta, C, inds=inds)
hessian2 = nd.Jacobian(lambda x: _ratematrix.loglikelihood(x, C)[1])(theta)
hessian3 = nd.Hessian(lambda x: _ratematrix.loglikelihood(x, C)[0])(theta)
np.set_printoptions(precision=3)
# H1 = hessian1[np.ix_(active, active)]
# H2 = hessian2[np.ix_(active, active)]
# H3 = hessian2[np.ix_(active, active)]
print(hessian1, '\n')
print(hessian2, '\n')
# print(hessian3)
print('\n')
info1 = np.zeros((len(theta), len(theta)))
info2 = np.zeros((len(theta), len(theta)))
info1[np.ix_(inds, inds)] = scipy.linalg.pinv(-hessian1)
info2[np.ix_(inds, inds)] = scipy.linalg.pinv(-hessian2[np.ix_(inds, inds)])
print('Inverse Hessian')
print(info1)
print(info2)
# print(scipy.linalg.pinv(hessian2))
# print(scipy.linalg.pinv(hessian1)[np.ix_(last, last)])
# print(scipy.linalg.pinv(hessian2)[np.ix_(last, last)])
print(_ratematrix.sigma_pi(info1, theta, n))
print(_ratematrix.sigma_pi(info2, theta, n))
开发者ID:Eigenstate,项目名称:msmbuilder,代码行数:47,代码来源:test_ratematrix.py
示例9: test_score_2
def test_score_2():
from msmbuilder.example_datasets.muller import MULLER_PARAMETERS as PARAMS
ds = MullerPotential(random_state=0).get()['trajectories']
cluster = NDGrid(n_bins_per_feature=6,
min=[PARAMS['MIN_X'], PARAMS['MIN_Y']],
max=[PARAMS['MAX_X'], PARAMS['MAX_Y']])
assignments = cluster.fit_transform(ds)
test_indices = [5, 0, 4, 1, 2]
train_indices = [3, 6, 7, 8, 9]
model = ContinuousTimeMSM(lag_time=3, n_timescales=1)
model.fit([assignments[i] for i in train_indices])
test = model.score([assignments[i] for i in test_indices])
train = model.score_
print('train', train, 'test', test)
assert 1 <= test < 2
assert 1 <= train < 2
开发者ID:kyleabeauchamp,项目名称:msmbuilder,代码行数:17,代码来源:test_ratematrix.py
示例10: test_score_3
def test_score_3():
ds = MullerPotential(random_state=0).get_cached().trajectories
cluster = NDGrid(n_bins_per_feature=6,
min=[PARAMS['MIN_X'], PARAMS['MIN_Y']],
max=[PARAMS['MAX_X'], PARAMS['MAX_Y']])
assignments = cluster.fit_transform(ds)
train_indices = [9, 4, 3, 6, 2]
test_indices = [8, 0, 5, 7, 1]
model = ContinuousTimeMSM(lag_time=3, n_timescales=1, sliding_window=False,
ergodic_cutoff=1)
train_data = [assignments[i] for i in train_indices]
test_data = [assignments[i] for i in test_indices]
model.fit(train_data)
train = model.score_
test = model.score(test_data)
print(train, test)
开发者ID:Eigenstate,项目名称:msmbuilder,代码行数:20,代码来源:test_ratematrix.py
示例11: test_score_3
def test_score_3():
from msmbuilder.example_datasets.muller import MULLER_PARAMETERS as PARAMS
cluster = NDGrid(n_bins_per_feature=6,
min=[PARAMS['MIN_X'], PARAMS['MIN_Y']],
max=[PARAMS['MAX_X'], PARAMS['MAX_Y']])
ds = MullerPotential(random_state=0).get()['trajectories']
assignments = cluster.fit_transform(ds)
train_indices = [9, 4, 3, 6, 2]
test_indices = [8, 0, 5, 7, 1]
model = ContinuousTimeMSM(lag_time=3, n_timescales=1, sliding_window=False, ergodic_cutoff=1)
train_data = [assignments[i] for i in train_indices]
test_data = [assignments[i] for i in test_indices]
model.fit(train_data)
train = model.score_
test = model.score(test_data)
print(train, test)
开发者ID:rmcgibbo,项目名称:msmbuilder,代码行数:21,代码来源:test_ratematrix.py
示例12: test_hessian
def test_hessian():
grid = NDGrid(n_bins_per_feature=10, min=-np.pi, max=np.pi)
seqs = grid.fit_transform(load_doublewell(random_state=0)['trajectories'])
seqs = [seqs[i] for i in range(10)]
lag_time = 10
model = ContinuousTimeMSM(verbose=True, lag_time=lag_time)
model.fit(seqs)
msm = MarkovStateModel(verbose=False, lag_time=lag_time)
print(model.summarize())
print('MSM timescales\n', msm.fit(seqs).timescales_)
print('Uncertainty K\n', model.uncertainty_K())
print('Uncertainty pi\n', model.uncertainty_pi())
开发者ID:synapticarbors,项目名称:msmbuilder-1,代码行数:13,代码来源:test_ratematrix.py
示例13: test_hessian_3
def test_hessian_3():
grid = NDGrid(n_bins_per_feature=4, min=-np.pi, max=np.pi)
trajs = DoubleWell(random_state=0).get_cached().trajectories
seqs = grid.fit_transform(trajs)
seqs = [seqs[i] for i in range(10)]
lag_time = 10
model = ContinuousTimeMSM(verbose=False, lag_time=lag_time)
model.fit(seqs)
msm = MarkovStateModel(verbose=False, lag_time=lag_time)
print(model.summarize())
# print('MSM timescales\n', msm.fit(seqs).timescales_)
print('Uncertainty K\n', model.uncertainty_K())
print('Uncertainty eigs\n', model.uncertainty_eigenvalues())
开发者ID:Eigenstate,项目名称:msmbuilder,代码行数:14,代码来源:test_ratematrix.py
示例14: test_fit_2
def test_fit_2():
grid = NDGrid(n_bins_per_feature=5, min=-np.pi, max=np.pi)
seqs = grid.fit_transform(load_doublewell(random_state=0)['trajectories'])
model = ContinuousTimeMSM(verbose=True, lag_time=10)
model.fit(seqs)
t1 = np.sort(model.timescales_)
t2 = -1/np.sort(np.log(np.linalg.eigvals(model.transmat_))[1:])
model = MarkovStateModel(verbose=False, lag_time=10)
model.fit(seqs)
t3 = np.sort(model.timescales_)
np.testing.assert_array_almost_equal(t1, t2)
# timescales should be similar to MSM (withing 50%)
assert abs(t1[-1] - t3[-1]) / t1[-1] < 0.50
开发者ID:synapticarbors,项目名称:msmbuilder-1,代码行数:16,代码来源:test_ratematrix.py
示例15: test_guess
def test_guess():
ds = MullerPotential(random_state=0).get_cached().trajectories
cluster = NDGrid(n_bins_per_feature=5,
min=[PARAMS['MIN_X'], PARAMS['MIN_Y']],
max=[PARAMS['MAX_X'], PARAMS['MAX_Y']])
assignments = cluster.fit_transform(ds)
model1 = ContinuousTimeMSM(guess='log')
model1.fit(assignments)
model2 = ContinuousTimeMSM(guess='pseudo')
model2.fit(assignments)
diff = model1.loglikelihoods_[-1] - model2.loglikelihoods_[-1]
assert np.abs(diff) < 1e-3
assert np.max(np.abs(model1.ratemat_ - model2.ratemat_)) < 1e-1
开发者ID:Eigenstate,项目名称:msmbuilder,代码行数:16,代码来源:test_ratematrix.py
示例16: test_guess
def test_guess():
from msmbuilder.example_datasets.muller import MULLER_PARAMETERS as PARAMS
cluster = NDGrid(n_bins_per_feature=5,
min=[PARAMS['MIN_X'], PARAMS['MIN_Y']],
max=[PARAMS['MAX_X'], PARAMS['MAX_Y']])
ds = MullerPotential(random_state=0).get()['trajectories']
assignments = cluster.fit_transform(ds)
model1 = ContinuousTimeMSM(guess='log')
model1.fit(assignments)
model2 = ContinuousTimeMSM(guess='pseudo')
model2.fit(assignments)
assert np.abs(model1.loglikelihoods_[-1] - model2.loglikelihoods_[-1]) < 1e-3
assert np.max(np.abs(model1.ratemat_ - model2.ratemat_)) < 1e-1
开发者ID:rmcgibbo,项目名称:msmbuilder,代码行数:18,代码来源:test_ratematrix.py
示例17: test_score_1
def test_score_1():
grid = NDGrid(n_bins_per_feature=5, min=-np.pi, max=np.pi)
seqs = grid.fit_transform(load_doublewell(random_state=0)['trajectories'])
model = ContinuousTimeMSM(verbose=False, lag_time=10, n_timescales=3).fit(seqs)
np.testing.assert_approx_equal(model.score(seqs), model.score_)
开发者ID:synapticarbors,项目名称:msmbuilder-1,代码行数:5,代码来源:test_ratematrix.py
注:本文中的msmbuilder.msm.ContinuousTimeMSM类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论