SFI.inference.sparse.stlsq module

SFI.inference.sparse.stlsq — Sequential Thresholded Least Squares

The STLSQStrategy implements the iterative hard-thresholding algorithm popularised by SINDy (Brunton et al., 2016):

  1. Solve the full problem \(G\,C = M\).

  2. Zero out coefficients whose magnitude falls below a threshold.

  3. Re-solve on the surviving support.

  4. Repeat until convergence.

The threshold can be absolute (mode="absolute") or relative to the current maximum coefficient magnitude (mode="relative", default — matches the PySINDy convention).

Running over a sweep of thresholds produces a Pareto front.

class SFI.inference.sparse.stlsq.STLSQStrategy(*, threshold=None, mode='relative', max_iter=50, n_thresholds=30, report_time=False)[source]

Bases: SparsityStrategy

Sequential Thresholded Least Squares (SINDy-style).

Parameters:
  • threshold (float or None) – Single threshold value. If None, an automatic log-spaced sweep from a small fraction of the maximum coefficient up to the maximum is performed.

  • mode ("relative" | "absolute", default "relative") – Whether threshold is interpreted as a fraction of \(\max|C|\) (relative) or a fixed value (absolute).

  • max_iter (int, default 50) – Maximum STLSQ iterations per threshold.

  • n_thresholds (int, default 30) – Number of thresholds in the automatic sweep (used only when threshold is None).

  • report_time (bool, default False) – Log elapsed wall-clock time when done.

name: str = 'stlsq'

Short identifier used in SparsityResult.method.

run(scorer, *, max_k, **_kwargs)[source]

Execute the search and return a SparsityResult.

Parameters:
  • scorer (SparseScorer) – Provides info_and_coeffs / vmap_info for evaluating candidate supports.

  • max_k (int) – Maximum model size to explore.

Return type:

SparsityResult