The KalmanFilter is a torch.nn.Module which generates forecasts using the full kalman-filtering
algorithm (or optionally extended-kalman filtering, if any measure-funs or nonlinear processes are used).
This class inherits most of its methods from torchcast.state_space.StateSpaceModel.
Bases: StateSpaceModel
processes – A list of Process modules.
measures – A list of strings specifying the names of the dimensions of the time-series being measured.
measure_covariance – A module created with Covariance.from_measures(measures).
process_covariance – A module created with Covariance.from_processes(processes, type='process').
initial_covariance – A module created with Covariance.from_processes(measures, type='initial').
measure_funs – A dictionary mapping measure-names to measurement-functions. Currently only supports ‘sigmoid’.
adaptive_scaling – Experimental feature to adaptively scale the covariance as a function of residuals. This is useful if different groups have very different magnitudes.
joseph_form – If True (the default), the update-step uses the Joseph form of the covariance update,
(I - K H) P (I - K H)' + K R K'. This keeps the covariance positive semi-definite even with numerical error in
the kalman gain K (which then only has a second-order effect). False uses the simpler P - K H P
(symmetrized): less memory during training (its intermediate results, kept for the backward pass, are smaller)
and faster, but errors in K have a first-order effect, so the covariance can lose positive-definiteness –
e.g. with float32, long series, near-zero process-variances, or very precise measurements.
mixture – Experimental. A MixtureModel (or a list of MixtureComponent objects); see
StateSpaceModel.