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
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
Evaluate cost function at current solution point.
Optimize until convergence criteria are met.