Skip to content

KalmanFilterTransformerSIMD

KalmanFilterTransformerSIMD

class KalmanFilterTransformerSIMD(state_dim, state_transition=None, process_noise=None, measurement_noise=None, measurement_function=None, initial_state=None, initial_state_covariance=None, denoising=False, hidden=True)[source]

Vectorized Kalman Filter from simdkalman.

The Kalman Filter is an unsupervised algorithm, consisting of several mathematical equations which are used to create an estimate of the state of a process.

The Kalman Filter is typically used for denoising data, or inferring the hidden state of data.

This class is the adapter for the simdkalman package into sktime. KalmanFilterTransformerSIMD implements hidden inferred states and denoising, depending on the boolean input parameter hidden. In addition, filtering (forward pass only) and smoothing (forward and backward pass) options can be selected with the denoising parameter.

The simdkalman package is ideal for Panels where similar Kalman Filters are applied in to multiple time series. The package applies multi-dimensional matrix operations, which can be an order of magnitude faster than the non-vectorized implementations.

This version does not currently support the EM algorithm or dynamic inputs, i.e., list of matrices per time-step.

Parameters:
state_dimint

System state feature dimension.

state_transitionnp.ndarray, optional (default=None)

of shape (state_dim, state_dim). State transition matrix, also referred to as F, is a matrix which describes the way the underlying series moves through successive time periods. Called A in simdkalman.

process_noisenp.ndarray, optional (default=None)

of shape (state_dim, state_dim). Process noise matrix, also referred to as Q, the uncertainty of the dynamic model.

measurement_noisenp.ndarray, optional (default=None)

of shape (measurement_dim, measurement_dim). Measurement noise matrix, also referred to as R, represents the uncertainty of the measurements.

measurement_functionnp.ndarray, optional (default=None)

of shape (measurement_dim, state_dim). Measurement equation matrix, also referred to as H, adjusts dimensions of measurements to match dimensions of state.

initial_statenp.ndarray, optional (default=None)

of shape (state_dim,). Initial estimated system state, also referred to as X0.

initial_state_covariancenp.ndarray, optional (default=None)

of shape (state_dim, state_dim). Initial estimated system state covariance, also referred to as P0.

denoisingbool, optional (default=False).

This parameter affects transform. If False, then transform will use a Kalman filter (forward pass only). If true, uses a Kalman smoother.

hiddenbool, optional (default=True).

This parameter affects transform. If True, then transform will be inferring hidden state. If False, returns smoothed/filtered observations (see also denoising), which always has the same dimensions as the input data, independent of the hidden state dimension.

Attributes:
is_fitted

Whether fit has been called.

See also

KalmanFilterTransformerPK

Kalman Filter transformer, adapter for the pykalman package into sktime.

KalmanFilterTransformerFP

Kalman Filter transformer, adapter for the filterpy package into sktime.

Notes

simdkalman documentation :

https://simdkalman.readthedocs.io/

>>> import numpy as np
>>> import time
>>> from sktime.utils._testing.panel import make_transformer_problem
>>> from sktime.transformations.kalman_filter import (
...     KalmanFilterTransformerPK,
...     KalmanFilterTransformerSIMD,
... )
>>>
>>> # Test data
>>> X = make_transformer_problem(
...     n_instances=200,
...     n_columns=2,
...     n_timepoints=500
... )
>>>
>>> kf_params = dict(
...     state_dim=2,
...     state_transition=np.array([[1, 1], [0, 1]]),
...     process_noise=np.diag([1e-6, 0.01]),
...     measurement_function=np.array([[1, 0], [0, 1]]),
...     measurement_noise=np.diag([10, 10]),
...     initial_state=np.array([0, -1]),
...     initial_state_covariance=np.diag([1, 1]),
... )
>>>
>>> t0 = time.time()
>>> kf_SIMD = KalmanFilterTransformerSIMD(**kf_params)
>>> X_SIMD = kf_SIMD.fit_transform(X)
>>> T_SIMD = time.time() - t0

Methods

check_is_fitted([method_name])

Check if the estimator has been fitted.

clone()

Obtain a clone of the object with same hyper-parameters and config.

clone_tags(estimator[, tag_names])

Clone tags from another object as dynamic override.

create_test_instance([parameter_set])

Construct an instance of the class, using first test parameter set.

create_test_instances_and_names([parameter_set])

Create list of all test instances and a list of names for them.

fit(X[, y])

Fit transformer to X, optionally to y.

fit_transform(X[, y])

Fit to data, then transform it.

get_class_tag(tag_name[, tag_value_default])

Get class tag value from class, with tag level inheritance from parents.

get_class_tags()

Get class tags from class, with tag level inheritance from parent classes.

get_config()

Get config flags for self.

get_fitted_params([deep])

Get fitted parameters.

get_param_defaults()

Get object's parameter defaults.

get_param_names([sort])

Get object's parameter names.

get_params([deep])

Get a dict of parameters values for this object.

get_tag(tag_name[, tag_value_default, ...])

Get tag value from instance, with tag level inheritance and overrides.

get_tags()

Get tags from instance, with tag level inheritance and overrides.

get_test_params([parameter_set])

Return testing parameter settings for the estimator.

inverse_transform(X[, y])

Inverse transform X and return an inverse transformed version.

is_composite()

Check if the object is composed of other BaseObjects.

load_from_path(serial)

Load object from file location.

load_from_serial(serial)

Load object from serialized memory container.

reset()

Reset the object to a clean post-init state.

save([path, serialization_format])

Save serialized self to bytes-like object or to (.zip) file.

set_config(**config_dict)

Set config flags to given values.

set_params(**params)

Set the parameters of this object.

set_random_state([random_state, deep, ...])

Set random_state pseudo-random seed parameters for self.

set_tags(**tag_dict)

Set instance level tag overrides to given values.

transform(X[, y])

Transform X and return a transformed version.

update(X[, y, update_params])

Update transformer with X, optionally y.