本文整理汇总了Python中msmbuilder.msm.MarkovStateModel.partial_transform方法的典型用法代码示例。如果您正苦于以下问题:Python MarkovStateModel.partial_transform方法的具体用法?Python MarkovStateModel.partial_transform怎么用?Python MarkovStateModel.partial_transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msmbuilder.msm.MarkovStateModel
的用法示例。
在下文中一共展示了MarkovStateModel.partial_transform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_partial_transform
# 需要导入模块: from msmbuilder.msm import MarkovStateModel [as 别名]
# 或者: from msmbuilder.msm.MarkovStateModel import partial_transform [as 别名]
def test_partial_transform():
model = MarkovStateModel()
model.fit([['a', 'a', 'b', 'b', 'c', 'c', 'a', 'a']])
assert model.mapping_ == {'a': 0, 'b': 1, 'c': 2}
v = model.partial_transform(['a', 'b', 'c'])
assert isinstance(v, list)
assert len(v) == 1
assert v[0].dtype == np.int
np.testing.assert_array_equal(v[0], [0, 1, 2])
v = model.partial_transform(['a', 'b', 'c', 'd'], 'clip')
assert isinstance(v, list)
assert len(v) == 1
assert v[0].dtype == np.int
np.testing.assert_array_equal(v[0], [0, 1, 2])
v = model.partial_transform(['a', 'b', 'c', 'd'], 'fill')
assert isinstance(v, np.ndarray)
assert len(v) == 4
assert v.dtype == np.float
np.testing.assert_array_equal(v, [0, 1, 2, np.nan])
v = model.partial_transform(['a', 'a', 'SPLIT', 'b', 'b', 'b'], 'clip')
assert isinstance(v, list)
assert len(v) == 2
assert v[0].dtype == np.int
assert v[1].dtype == np.int
np.testing.assert_array_equal(v[0], [0, 0])
np.testing.assert_array_equal(v[1], [1, 1, 1])
示例2: load_trajs
# 需要导入模块: from msmbuilder.msm import MarkovStateModel [as 别名]
# 或者: from msmbuilder.msm.MarkovStateModel import partial_transform [as 别名]
"""Make a microstate MSM
{{header}}
"""
from msmbuilder.io import load_trajs, save_trajs, save_generic
from msmbuilder.msm import MarkovStateModel
## Load
meta, ktrajs = load_trajs('ktrajs')
## Fit
msm = MarkovStateModel(lag_time=2, n_timescales=10, verbose=False)
msm.fit(list(ktrajs.values()))
## Transform
microktrajs = {}
for k, v in ktrajs.items():
microktrajs[k] = msm.partial_transform(v)
## Save
print(msm.summarize())
save_generic(msm, 'msm.pickl')
save_trajs(microktrajs, 'microktrajs', meta)