Binomial Filter

The BinomialFilter is a KalmanFilter with (1) one or more sigmoid measurement-functions and (2) with a log_prob that use binomial likelihood (using monte-carlo approximation).

class torchcast.kalman_filter.binomial_filter.BinomialFilter(processes: Sequence[Process], measures: Sequence[str] | None, binary_measures: Sequence[str] | None = None, observed_counts: bool | None = None, do_post_hoc_correction: bool = True, measure_covariance: Covariance | dict | None = None, process_covariance: Covariance | None = None, initial_covariance: Covariance | None = None, adaptive_scaling: bool = False)

Bases: KalmanFilter

Parameters:
  • processes – A list of Process modules.

  • measures – A list of strings specifying the names of the dimensions of the time-series being measured.

  • binary_measures – A subset of measures with binary (binomial) outcomes.

  • observed_counts – If True, then y is interpreted as counts; if False then as probabilities 0-1.

  • do_post_hoc_correction – Default True. Apply correction to the binary residuals during the update step, to compensate for the linearization error introduced by the EKF approximation. The exact correction is learned: a learned baseline correction level is modulated by a learned increase/decrease according to num_obs.

  • 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').

  • adaptive_scaling – Experimental feature to adaptively scale the covariance as a function of residuals. This is useful if different groups have very different magnitudes.