本文整理汇总了Python中msmbuilder.msm.ContinuousTimeMSM.fit方法的典型用法代码示例。如果您正苦于以下问题:Python ContinuousTimeMSM.fit方法的具体用法?Python ContinuousTimeMSM.fit怎么用?Python ContinuousTimeMSM.fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msmbuilder.msm.ContinuousTimeMSM
的用法示例。
在下文中一共展示了ContinuousTimeMSM.fit方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_doublewell
# 需要导入模块: from msmbuilder.msm import ContinuousTimeMSM [as 别名]
# 或者: from msmbuilder.msm.ContinuousTimeMSM import fit [as 别名]
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
示例2: test_fit_1
# 需要导入模块: from msmbuilder.msm import ContinuousTimeMSM [as 别名]
# 或者: from msmbuilder.msm.ContinuousTimeMSM import fit [as 别名]
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_)
示例3: test_hessian
# 需要导入模块: from msmbuilder.msm import ContinuousTimeMSM [as 别名]
# 或者: from msmbuilder.msm.ContinuousTimeMSM import fit [as 别名]
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())
示例4: test_dump
# 需要导入模块: from msmbuilder.msm import ContinuousTimeMSM [as 别名]
# 或者: from msmbuilder.msm.ContinuousTimeMSM import fit [as 别名]
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)
示例5: test_hessian_3
# 需要导入模块: from msmbuilder.msm import ContinuousTimeMSM [as 别名]
# 或者: from msmbuilder.msm.ContinuousTimeMSM import fit [as 别名]
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())
示例6: test_fit_2
# 需要导入模块: from msmbuilder.msm import ContinuousTimeMSM [as 别名]
# 或者: from msmbuilder.msm.ContinuousTimeMSM import fit [as 别名]
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
示例7: test_guess
# 需要导入模块: from msmbuilder.msm import ContinuousTimeMSM [as 别名]
# 或者: from msmbuilder.msm.ContinuousTimeMSM import fit [as 别名]
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
示例8: test_score_2
# 需要导入模块: from msmbuilder.msm import ContinuousTimeMSM [as 别名]
# 或者: from msmbuilder.msm.ContinuousTimeMSM import fit [as 别名]
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
示例9: test_score_2
# 需要导入模块: from msmbuilder.msm import ContinuousTimeMSM [as 别名]
# 或者: from msmbuilder.msm.ContinuousTimeMSM import fit [as 别名]
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
示例10: test_guess
# 需要导入模块: from msmbuilder.msm import ContinuousTimeMSM [as 别名]
# 或者: from msmbuilder.msm.ContinuousTimeMSM import fit [as 别名]
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