mushi.optimization.TrendFilter

class TrendFilter(ks, lambdas, rhos=None, verbose=False)[source]

Bases: mushi.optimization.Optimizer

Mixed trend filtering via specialized ADMM as in 3, section 5.2.

The optimization problem solved is:

\[\arg\min_{\beta \in \mathbb{R}} \frac{1}{2} \|y - \beta\|_2^2 + \sum_{\ell=1}^r \lambda_\ell \| D^{k_\ell + 1} \beta \|_1\]

where \(r\) is the number of elements of k.

Parameters
  • ks (Tuple[int]) – tuple of integer trend filter orders

  • lambdas (Tuple[float64]) – tuple of penalties corresponding to each k

  • rhos (Optional[Tuple[float64]]) – ADMM convergence parameter

  • verbose (bool) – print convergence messages

References

3

Aaditya Ramdas and Ryan J. Tibshirani. Fast and flexible admm algorithms for trend filtering. Journal of Computational and Graphical Statistics 25.3 (2016): 839-858.

Example

>>> import mushi.optimization as opt
>>> import numpy as np

Define piecewise constant input signal

>>> x = np.zeros(10)
>>> x[3:7] = 1
>>> x
array([0., 0., 0., 1., 1., 1., 1., 0., 0., 0.])

Corrupt the signal with additive noise

>>> np.random.seed(0)
>>> x += .1 * np.random.randn(10)

Initialize and run 0-th order trend filter on input signal

>>> tf = opt.TrendFilter((0,), (1e-1,))
>>> tf.run(x)
array([0.13810345, 0.13809355, 0.13809775, 1.10542391, 1.1054212 ,
       0.99863353, 0.99864752, 0.03853261, 0.03853295, 0.03853668])

Methods

f

Evaluate cost function at current solution point.

run

Optimize until convergence criteria are met.

f()[source]

Evaluate cost function at current solution point.

run(x, tol=1e-06, max_iter=100)

Optimize until convergence criteria are met.

Parameters
  • x (ndarray) – initial point

  • tol (float64) – relative tolerance in objective function

  • max_iter (int) – maximum number of iterations

Returns

solution point

Return type

x