incline.L1TrendFilter

class incline.L1TrendFilter(lambda_param=1.0, lambda_fraction=None, difference_order=2, max_iter=100, tol=0.0001)[source]

L1 trend filtering: piecewise-polynomial fit with sparse kinks.

Solved by ADMM. The soft-thresholding step is nonlinear in the data – that is the whole point, since it is what produces changepoints – so uncertainty is bootstrapped.

Note that the penalty’s difference order and the derivative being reported are separate things; the previous implementation used one parameter for both.

Variables:
  • lambda_param (float) – Absolute penalty on the differences. Larger means fewer kinks. Ignored when lambda_fraction is set.

  • lambda_fraction (float | None) – Penalty as a fraction of the value above which the fit collapses to a plain polynomial. Being relative to the data is what makes it comparable across series; an absolute penalty is not.

  • difference_order (int) – Order of the penalized difference. Two gives a piecewise-linear trend, the usual choice.

  • max_iter (int) – ADMM iteration cap.

  • tol (float) – Convergence tolerance on the primal variable.

Parameters:
__init__(lambda_param=1.0, lambda_fraction=None, difference_order=2, max_iter=100, tol=0.0001)
Parameters:
Return type:

None

Methods

__init__([lambda_param, lambda_fraction, ...])

analytic_operators(axis, order)

State the smoothing and derivative operators directly, if known.

evaluate(axis, y, order)

Solve the L1 trend filtering problem, then difference the fit.

fit(axis, y[, order, se, noise, ...])

Estimate the trend and, optionally, its uncertainty.

native_posterior(axis, y, order, ...)

Uncertainty from the smoother's own probability model.

operators(axis, order)

The smoothing and derivative operators for this configuration.

params()

Report the penalty and difference order.

scale_of(axis)

The relative penalty is already a scale.

with_scale(scale, axis)

Set the penalty as a fraction of its saturating value.

Attributes

difference_order

has_native_posterior

is_linear

Whether the derivative is a fixed linear map of the data.

lambda_fraction

lambda_param

linear

max_iter

name

requires_regular_grid

supported_orders

tol

name: ClassVar[str] = 'l1_filter'
lambda_param: float = 1.0
lambda_fraction: float | None = None
difference_order: int = 2
max_iter: int = 100
tol: float = 0.0001
evaluate(axis, y, order)[source]

Solve the L1 trend filtering problem, then difference the fit.

Parameters:
  • axis (TimeAxis)

  • y (npt.NDArray[np.float64])

  • order (int)

Return type:

Evaluation

with_scale(scale, axis)[source]

Set the penalty as a fraction of its saturating value.

Parameters:
Return type:

Self

scale_of(axis)[source]

The relative penalty is already a scale.

Parameters:

axis (TimeAxis)

Return type:

float

params()[source]

Report the penalty and difference order.

Return type:

dict[str, Any]