affine.fused_lasso¶
Module: affine.fused_lasso
¶
Inheritance diagram for regreg.affine.fused_lasso
:
Classes¶
trend_filter
¶
-
class
regreg.affine.fused_lasso.
trend_filter
(knots, order=1, sorted=False)¶ Bases:
regreg.affine.affine_transform
-
__init__
(knots, order=1, sorted=False)¶ Create affine transform
- Parameters
linear_operator : None or ndarray or sparse array or affine_transform
Linear part of affine transform implemented as array or as affine_transform. None results in no linear component.
affine_offset : None or ndarray
offset component of affine. Only one of linear_operator and affine_offset can be None, because we need an input array to define the shape of the transform.
diag : {False, True}, optional
If True, interpret 1D linear_operator as the main diagonal of the a diagonal array, so that
linear_operator = np.diag(linear_operator)
-
property
T
¶
-
adjoint_map
(x)¶ Apply transpose of linear component to u
Return \(D^Tu\)
- Parameters
u : ndarray
array to which to apply transposed linear part of transform. Can be 1D or 2D array
copy : {True, False}, optional
If True, in situations where return is identical to u, ensure returned value is a copy.
- Returns
DTu : ndarray
u transformed with transpose of linear component
Notes
This routine is currently a matrix multiplication, but could also call FFTs if D is a DFT matrix, in a subclass.
-
affine_map
(x)¶ Apply linear and affine offset to x
Return \(Dx+\alpha\)
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
copy : {True, False}, optional
If True, in situations where return is identical to x, ensure returned value is a copy.
- Returns
Dx_a : ndarray
x transformed with linear and offset components
Notes
This routine is subclassed in affine_atom as a matrix multiplications, but could also call FFTs if D is a DFT matrix, in a subclass.
-
dot
(x)¶ Apply linear part of transform to x. Returns self.linear_map(x) unless x is a transform, in which case it returns the composition.
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
- Returns
Dx : ndarray
x transformed with linear component
-
classmethod
grid
(m, order=1, sorted=False)¶
-
linear_map
(x)¶ Apply linear part of transform to x
Return \(Dx\)
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
- Returns
Dx : ndarray
x transformed with linear component
Notes
This routine is subclassed in affine_atom as a matrix multiplications, but could also call FFTs if D is a DFT matrix, in a subclass.
-
property
ndim
¶
-
property
shape
¶
-
trend_filter_inverse
¶
-
class
regreg.affine.fused_lasso.
trend_filter_inverse
(knots, order=1, sorted=False)¶ Bases:
regreg.affine.affine_transform
-
__init__
(knots, order=1, sorted=False)¶ Create affine transform
- Parameters
linear_operator : None or ndarray or sparse array or affine_transform
Linear part of affine transform implemented as array or as affine_transform. None results in no linear component.
affine_offset : None or ndarray
offset component of affine. Only one of linear_operator and affine_offset can be None, because we need an input array to define the shape of the transform.
diag : {False, True}, optional
If True, interpret 1D linear_operator as the main diagonal of the a diagonal array, so that
linear_operator = np.diag(linear_operator)
-
property
T
¶
-
adjoint_map
(x)¶ Apply transpose of linear component to u
Return \(D^Tu\)
- Parameters
u : ndarray
array to which to apply transposed linear part of transform. Can be 1D or 2D array
copy : {True, False}, optional
If True, in situations where return is identical to u, ensure returned value is a copy.
- Returns
DTu : ndarray
u transformed with transpose of linear component
Notes
This routine is currently a matrix multiplication, but could also call FFTs if D is a DFT matrix, in a subclass.
-
affine_map
(x)¶ Apply linear and affine offset to x
Return \(Dx+\alpha\)
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
copy : {True, False}, optional
If True, in situations where return is identical to x, ensure returned value is a copy.
- Returns
Dx_a : ndarray
x transformed with linear and offset components
Notes
This routine is subclassed in affine_atom as a matrix multiplications, but could also call FFTs if D is a DFT matrix, in a subclass.
-
dot
(x)¶ Apply linear part of transform to x. Returns self.linear_map(x) unless x is a transform, in which case it returns the composition.
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
- Returns
Dx : ndarray
x transformed with linear component
-
classmethod
grid
(m, order=1, sorted=False)¶
-
linear_map
(x)¶ Apply linear part of transform to x
Return \(Dx\)
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
- Returns
Dx : ndarray
x transformed with linear component
Notes
This routine is subclassed in affine_atom as a matrix multiplications, but could also call FFTs if D is a DFT matrix, in a subclass.
-
property
ndim
¶
-
property
shape
¶
-
Function¶
-
regreg.affine.fused_lasso.
difference_transform
(X, order=1, sorted=False, transform=False)¶ Compute the divided difference matrix for X after sorting X.
- Parameters
X: np.array, np.float, ndim=1
X coordinates where discrete derivative is computed.
order: int
What order of difference should we compute?
sorted: bool
Is X sorted?
transform: bool
If True, return a linear_transform rather than a sparse matrix.
- Returns
D: np.array, ndim=2, shape=(n-order,order)
Matrix of divided differences of sorted X.