本文整理汇总了Python中pykalman.KalmanFilter.em_vars方法的典型用法代码示例。如果您正苦于以下问题:Python KalmanFilter.em_vars方法的具体用法?Python KalmanFilter.em_vars怎么用?Python KalmanFilter.em_vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykalman.KalmanFilter
的用法示例。
在下文中一共展示了KalmanFilter.em_vars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_kalman_fit
# 需要导入模块: from pykalman import KalmanFilter [as 别名]
# 或者: from pykalman.KalmanFilter import em_vars [as 别名]
def test_kalman_fit():
# check against MATLAB dataset
kf = KalmanFilter(
data.transition_matrix,
data.observation_matrix,
data.initial_transition_covariance,
data.initial_observation_covariance,
data.transition_offsets,
data.observation_offset,
data.initial_state_mean,
data.initial_state_covariance,
em_vars=['transition_covariance', 'observation_covariance'])
loglikelihoods = np.zeros(5)
for i in range(len(loglikelihoods)):
loglikelihoods[i] = kf.loglikelihood(data.observations)
kf.em(X=data.observations, n_iter=1)
assert_true(np.allclose(loglikelihoods, data.loglikelihoods[:5]))
# check that EM for all parameters is working
kf.em_vars = 'all'
n_timesteps = 30
for i in range(len(loglikelihoods)):
kf.em(X=data.observations[0:n_timesteps], n_iter=1)
loglikelihoods[i] = kf.loglikelihood(data.observations[0:n_timesteps])
for i in range(len(loglikelihoods) - 1):
assert_true(loglikelihoods[i] < loglikelihoods[i + 1])