atoms.sparse_group_lasso

Module: atoms.sparse_group_lasso

Inheritance diagram for regreg.atoms.sparse_group_lasso:

digraph inheritance89b2586f82 { rankdir=LR; size="8.0, 12.0"; "atoms.group_lasso.group_lasso" [URL="regreg.atoms.group_lasso.html#regreg.atoms.group_lasso.group_lasso",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="The group lasso seminorm."]; "atoms.seminorms.seminorm" -> "atoms.group_lasso.group_lasso" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.seminorms.seminorm" [URL="regreg.atoms.seminorms.html#regreg.atoms.seminorms.seminorm",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="An atom that can be in lagrange or bound form."]; "regreg.atoms.atom" -> "atoms.seminorms.seminorm" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.sparse_group_lasso.sparse_group_lasso" [URL="#regreg.atoms.sparse_group_lasso.sparse_group_lasso",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Sparse group LASSO"]; "atoms.group_lasso.group_lasso" -> "atoms.sparse_group_lasso.sparse_group_lasso" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.seminorms.seminorm" -> "atoms.sparse_group_lasso.sparse_group_lasso" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.sparse_group_lasso.sparse_group_lasso_dual" [URL="#regreg.atoms.sparse_group_lasso.sparse_group_lasso_dual",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="The dual of the slope penalty:math:`\ell_{\infty}` norm"]; "atoms.sparse_group_lasso.sparse_group_lasso" -> "atoms.sparse_group_lasso.sparse_group_lasso_dual" [arrowsize=0.5,style="setlinewidth(0.5)"]; "problems.composite.composite" [URL="regreg.problems.composite.html#regreg.problems.composite.composite",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A generic way to specify a problem in composite form."]; "problems.composite.nonsmooth" [URL="regreg.problems.composite.html#regreg.problems.composite.nonsmooth",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A composite subclass that explicitly returns 0"]; "problems.composite.composite" -> "problems.composite.nonsmooth" [arrowsize=0.5,style="setlinewidth(0.5)"]; "regreg.atoms.atom" [URL="regreg.atoms.html#regreg.atoms.atom",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A class that defines the API for support functions."]; "problems.composite.nonsmooth" -> "regreg.atoms.atom" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Implementation of the sparse group LASSO atom.

This penalty is defined by groups and individual feature weights and is $$ eta mapsto sum_j lambda_j |eta_j| + sum_g lpha_g |eta_g|_2 $$

Classes

sparse_group_lasso

class regreg.atoms.sparse_group_lasso.sparse_group_lasso(groups, lasso_weights, weights={}, lagrange=None, bound=None, offset=None, quadratic=None, initial=None)

Bases: regreg.atoms.group_lasso.group_lasso, regreg.atoms.seminorms.seminorm

Sparse group LASSO

__init__(groups, lasso_weights, weights={}, lagrange=None, bound=None, offset=None, quadratic=None, initial=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod affine(linear_operator, offset, lagrange=None, diag=False, bound=None, quadratic=None)

This is the same as the linear class method but with offset as a positional argument

apply_offset(x)

If self.offset is not None, return x-self.offset, else return x.

property bound
bound_prox(x, bound=None)

Return unique minimizer

\[{\beta}^{\delta}(\theta) = \text{argmin}_{\beta \in \mathbb{R}^{p}} \frac{1}{2} \|\theta-\beta\|^2_2 \ \text{s.t.} \ \left[ \sum_j \alpha_j |\beta_j| + \sum_g \lambda_g \|\beta[g]\|_2 \right] \leq \delta\]

where \(\delta\) is the bound parameter and \(\theta\) is arg.

If the argument bound is None and the atom is in bound mode, self.bound is used as the bound parameter, else an exception is raised.

The class atom’s bound_prox just returns the appropriate bound parameter for use by the subclasses.

Parameters

arg : np.ndarray(np.float)

Argument of the proximal map.

bound : float (optional)

Bound for the constraint on the seminorm. Defaults to self.bound.

Returns

Z : np.ndarray(np.float)

The proximal map of arg.

static check_subgradient(atom, prox_center)

For a given seminorm, verify the KKT condition for the problem for the proximal problem

\[\text{minimize}_u \frac{1}{2} \|u-z\|^2_2 + h(z)\]

where \(z\) is the prox_center and \(h\) is atom which may be in Lagrange or bound form.

If the atom is in Lagrange form, this function should return two values equal to the seminorm of the minimizer. If it is bound form it should return two values equal to the dual seminorm of the residual, i.e. the prox_center minus the minimizer.

Parameters

atom : seminorm

prox_center : np.ndarray(np.float)

Center for the proximal map.

Returns

v1, v2 : float

Two values that should be equal if the proximal map is correct.

property conjugate
constraint(x, bound=None)

Verify :math:` left[ sum_j alpha_j |\beta_j| + sum_g lambda_g |beta[g]|_2 right] leq delta`, where \(\delta\) is bound.

If the result is True, returns 0, else returns np.inf.

The class seminorm’s constraint just returns the appropriate bound parameter for use by the subclasses.

property dual
get_bound()

Get method of the bound property.

>>> import regreg.api as rr
>>> constraint = rr.group_lasso([1, 1, 2, 2, 2], bound=2.3) 
>>> constraint.bound
2.3
get_conjugate()

Return the conjugate of an given atom.

>>> import regreg.api as rr
>>> penalty = rr.sparse_group_lasso([1, 1, 2, 2, 2], [0, 0.5, 0.2, 0.2, 0.2], lagrange=3.4)
>>> penalty.get_conjugate() 
sparse_group_lasso_dual(..., bound=3.4...)
get_dual()

Return the dual of an atom. This dual is formed by making introducing new variables \(v=Ax\) where \(A\) is self.linear_transform.

>>> import regreg.api as rr
>>> penalty = rr.group_lasso([1, 1, 2, 2, 2], lagrange=2.3)
>>> penalty 
group_lasso(..., lagrange=2.3...)
>>> penalty.dual 
(<regreg.affine.identity object at 0x...>, group_lasso_dual(..., bound=2.3...))

If there is a linear part to the penalty, the linear_transform may not be identity. For example, the 1D fused LASSO penalty:

>>> D = (np.identity(4) + np.diag(-np.ones(3),1))[:-1]
>>> D
array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]])
>>> linear_atom = rr.l1norm.linear(D, lagrange=2.3)
>>> linear_atom 
affine_atom(l1norm((3,), lagrange=2.3...), array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]]))
>>> linear_atom.dual 
(<regreg.affine.linear_transform object at 0x...>, supnorm((3,), bound=2.3...))
get_lagrange()

Get method of the lagrange property.

>>> import regreg.api as rr
>>> penalty = rr.group_lasso([1, 1, 2, 2, 2], lagrange=3.4)
>>> penalty.lagrange
3.4
get_offset()
get_quadratic()

Get the quadratic part of the composite.

property lagrange
lagrange_prox(x, lipschitz=1, lagrange=None)

Return unique minimizer

\[{\beta}^{\lambda}(\theta) = \text{argmin}_{\beta \in \mathbb{R}^{p}} \frac{L}{2} \|\theta-\beta\|^2_2 + \lambda \left[ \sum_j \alpha_j |\beta_j| + \sum_g \lambda_g \|\beta[g]\|_2 \right] \]

Above, \(\lambda\) is the Lagrange parameter and \(L\) is the Lipschitz parameter and \(\theta\) is arg.

If the argument lagrange is None and the atom is in lagrange mode, self.lagrange is used as the lagrange parameter, else an exception is raised.

The class atom’s lagrange_prox just returns the appropriate lagrange parameter for use by the subclasses.

Parameters

arg : np.ndarray(np.float)

Argument of the proximal map.

lipschitz : float

Coefficient in front of the quadratic.

lagrange : float (optional)

Lagrange factor in front of the seminorm. Defaults to self.lagrange.

Returns

Z : np.ndarray(np.float)

The proximal map of arg.

latexify(var=None, idx='')

Return a LaTeX representation of an object.

>>> import regreg.api as rr
>>> penalty = rr.l1norm(10, lagrange=0.9)
>>> penalty.latexify(var=r'\gamma') 
'\\lambda_{} \\|\\gamma\\|_1'
Parameters

var : string

Argument of the functions

idx : string

Optional subscript index.

Returns

L : string

A LaTeX representation of the atom.

classmethod linear(linear_operator, lagrange=None, diag=False, bound=None, quadratic=None, offset=None)
property linear_transform

The linear transform applied before a penalty is computed. Defaults to regreg.affine.identity

>>> from regreg.api import l1norm
>>> penalty = l1norm(30, lagrange=3.4)
>>> type(penalty.linear_transform)
<class 'regreg.affine.identity'>
nonsmooth_objective(arg, check_feasibility=False)

The nonsmooth objective function of the atom. Includes self.quadratic.objective(arg).

>>> import regreg.api as rr
>>> penalty = rr.l1norm(4, lagrange=2)
>>> penalty.nonsmooth_objective([3, 4, 5, 9])
42.0
>>> 2 * sum([3, 4, 5, 9])
42
Parameters

arg : np.ndarray(np.float)

Argument of the seminorm.

check_feasibility : bool

If True, then return np.inf if appropriate.

Returns

value : np.float

The seminorm of arg.

objective(x, check_feasibility=False)
objective_template = ' \\left[ \\sum_j \\alpha_j |%(var)s_j| + \\sum_g \\lambda_g \\|%(var)s[g]\\|_2 \\right]'
objective_vars = {'dualnormklass': 'sparse_group_lasso_dual', 'initargs': '[1, 1, 2, 2, 2], [0, 0.5, 0.2, 0.2, 0.2]', 'linear': 'D', 'normklass': 'sparse_group_lasso', 'offset': '\\alpha', 'shape': 'p', 'var': '\\beta'}
property offset
proximal(quadratic, prox_control=None)

The proximal operator. If the atom is in Lagrange mode, this has the form

\[\beta^{\lambda}(\theta) = \text{argmin}_{\beta \in \mathbb{R}^{p}} \frac{L}{2} \|\theta-\beta\|^2_2 + \lambda h(\beta-\alpha) + \langle \beta, \eta \rangle\]

where \(\alpha\) is self.offset, \(\eta\) is quadratic.linear_term, \(\theta\) is quadratic.center and

\[h(\beta) = \sum_g w_g \|\beta[g]\|_2\]

If the atom is in bound mode, then this has the form

\[\beta^{\delta}(\theta) = \text{argmin}_{\beta \in \mathbb{R}^{p}} \frac{L}{2} \|\theta-\beta\|^2_2 + \langle \beta, \eta \rangle \ \text{s.t.} \ h(\beta - \alpha) \leq \delta\]
>>> import regreg.api as rr
>>> penalty = rr.l1norm(4, lagrange=2)
>>> Q = rr.identity_quadratic(1.5, [3, -4, -1, 1], 0, 0)
>>> penalty.proximal(Q) 
array([ 1.6666..., -2.6666..., -0.        ,  0.        ])
Parameters

quadratic : regreg.identity_quadratic.identity_quadratic

A quadratic added to the atom before minimizing.

prox_control : [None, dict]

This argument is ignored for seminorms, but otherwise is passed to regreg.algorithms.FISTA if the atom needs to be solved iteratively.

Returns

Z : np.ndarray(np.float)

The proximal map of the implied center of quadratic.

proximal_optimum(quadratic)
proximal_step(quadratic, prox_control=None)

Compute the proximal optimization

Parameters

prox_control: [None, dict]

If not None, then a dictionary of parameters for the prox procedure

property quadratic

Quadratic part of the object, instance of regreg.identity_quadratic.identity_quadratic.

seminorm(x, lagrange=None, check_feasibility=False)

Return \(\lambda \cdot \left[ \sum_j \alpha_j |\beta_j| + \sum_g \lambda_g \|\beta[g]\|_2 \right]\), where \(\lambda\) is lagrange. If check_feasibility is True, and seminorm is unbounded, will return np.inf if appropriate.

The class seminorm’s seminorm just returns the appropriate lagrange parameter for use by the subclasses.

set_bound(bound)

Set method of the bound property.

>>> import regreg.api as rr
>>> constraint = rr.group_lasso([1, 1, 2, 2, 2], bound=3.4) 
>>> constraint.bound
3.4
>>> constraint.bound = 2.3
>>> constraint.bound
2.3
>>> penalty = rr.group_lasso([1, 1, 2, 2, 2], lagrange=2.3)
>>> penalty.bound = 3.4 
Traceback (most recent call last):
...
AttributeError: atom is in lagrange mode
set_lagrange(lagrange)

Set method of the lagrange property.

>>> import regreg.api as rr
>>> penalty = rr.group_lasso([1, 1, 2, 2, 2], lagrange=3.4)
>>> penalty.lagrange
3.4
>>> penalty.lagrange = 2.3
>>> penalty.lagrange
2.3
>>> constraint = rr.group_lasso([1, 1, 2, 2, 2], bound=3.4)
>>> constraint.lagrange = 3.4 
Traceback (most recent call last):
...
AttributeError: atom is in bound mode
set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

set_weight(group, weight)

Set a group’s weight after initialization.

classmethod shift(offset, lagrange=None, diag=False, bound=None, quadratic=None)
smooth_objective(x, mode='both', check_feasibility=False)

The zero function.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)
terms(arg)

Return the args that are summed in computing the seminorm.

>>> import regreg.api as rr
>>> groups = [1,1,2,2,2]
>>> penalty = rr.group_lasso(groups, lagrange=1.)
>>> arg = [2,4,5,3,4]
>>> penalty.terms(arg) 
[6.3245..., 12.2474...]
>>> penalty.seminorm(arg) 
18.5720...
>>> np.sqrt((2**2 + 4**2)*2), np.sqrt((5**2 + 3**2 + 4**2) * 3.) 
(6.3245..., 12.2474...)
>>> np.sqrt((2**2 + 4**2)*2) + np.sqrt((5**2 + 3**2 + 4**2) * 3.) 
18.5720...
tol = 1e-05

sparse_group_lasso_dual

class regreg.atoms.sparse_group_lasso.sparse_group_lasso_dual(groups, lasso_weights, weights={}, lagrange=None, bound=None, offset=None, quadratic=None, initial=None)

Bases: regreg.atoms.sparse_group_lasso.sparse_group_lasso

The dual of the slope penalty:math:ell_{infty} norm

__init__(groups, lasso_weights, weights={}, lagrange=None, bound=None, offset=None, quadratic=None, initial=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod affine(linear_operator, offset, lagrange=None, diag=False, bound=None, quadratic=None)

This is the same as the linear class method but with offset as a positional argument

apply_offset(x)

If self.offset is not None, return x-self.offset, else return x.

property base_conjugate

For a sparse group LASSO dual in bound form, an atom that agrees with its primal Lagrange form.

Note: this conjugate does not take into account the atom’s quadratic and offset terms.

property bound
bound_prox(x, bound=None)

Return unique minimizer

\[{\beta}^{\delta}(\theta) = \text{argmin}_{\beta \in \mathbb{R}^{p}} \frac{1}{2} \|\theta-\beta\|^2_2 \ \text{s.t.} \ {\cal D}^{group sparse}(\beta) \leq \delta\]

where \(\delta\) is the bound parameter and \(\theta\) is arg.

If the argument bound is None and the atom is in bound mode, self.bound is used as the bound parameter, else an exception is raised.

The class atom’s bound_prox just returns the appropriate bound parameter for use by the subclasses.

Parameters

arg : np.ndarray(np.float)

Argument of the proximal map.

bound : float (optional)

Bound for the constraint on the seminorm. Defaults to self.bound.

Returns

Z : np.ndarray(np.float)

The proximal map of arg.

static check_subgradient(atom, prox_center)

For a given seminorm, verify the KKT condition for the problem for the proximal problem

\[\text{minimize}_u \frac{1}{2} \|u-z\|^2_2 + h(z)\]

where \(z\) is the prox_center and \(h\) is atom which may be in Lagrange or bound form.

If the atom is in Lagrange form, this function should return two values equal to the seminorm of the minimizer. If it is bound form it should return two values equal to the dual seminorm of the residual, i.e. the prox_center minus the minimizer.

Parameters

atom : seminorm

prox_center : np.ndarray(np.float)

Center for the proximal map.

Returns

v1, v2 : float

Two values that should be equal if the proximal map is correct.

property conjugate
constraint(x, bound=None)

Verify \({\cal D}^{group sparse}(\beta) \leq \delta\), where \(\delta\) is bound.

If the result is True, returns 0, else returns np.inf.

The class seminorm’s constraint just returns the appropriate bound parameter for use by the subclasses.

property dual
get_bound()

Get method of the bound property.

>>> import regreg.api as rr
>>> constraint = rr.group_lasso([1, 1, 2, 2, 2], bound=2.3) 
>>> constraint.bound
2.3
get_conjugate()

Return the conjugate of an given atom.

>>> import regreg.api as rr
>>> penalty = rr.sparse_group_lasso([1, 1, 2, 2, 2], [0, 0.5, 0.2, 0.2, 0.2], lagrange=3.4)
>>> penalty.get_conjugate() 
sparse_group_lasso_dual(..., bound=3.4...)
get_dual()

Return the dual of an atom. This dual is formed by making introducing new variables \(v=Ax\) where \(A\) is self.linear_transform.

>>> import regreg.api as rr
>>> penalty = rr.group_lasso([1, 1, 2, 2, 2], lagrange=2.3)
>>> penalty 
group_lasso(..., lagrange=2.3...)
>>> penalty.dual 
(<regreg.affine.identity object at 0x...>, group_lasso_dual(..., bound=2.3...))

If there is a linear part to the penalty, the linear_transform may not be identity. For example, the 1D fused LASSO penalty:

>>> D = (np.identity(4) + np.diag(-np.ones(3),1))[:-1]
>>> D
array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]])
>>> linear_atom = rr.l1norm.linear(D, lagrange=2.3)
>>> linear_atom 
affine_atom(l1norm((3,), lagrange=2.3...), array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]]))
>>> linear_atom.dual 
(<regreg.affine.linear_transform object at 0x...>, supnorm((3,), bound=2.3...))
get_lagrange()

Get method of the lagrange property.

>>> import regreg.api as rr
>>> penalty = rr.group_lasso([1, 1, 2, 2, 2], lagrange=3.4)
>>> penalty.lagrange
3.4
get_offset()
get_quadratic()

Get the quadratic part of the composite.

property lagrange
lagrange_prox(x, lipschitz=1, lagrange=None)

Return unique minimizer

\[{\beta}^{\lambda}(\theta) = \text{argmin}_{\beta \in \mathbb{R}^{p}} \frac{L}{2} \|\theta-\beta\|^2_2 + \lambda {\cal D}^{group sparse}(\beta) \]

Above, \(\lambda\) is the Lagrange parameter and \(L\) is the Lipschitz parameter and \(\theta\) is arg.

If the argument lagrange is None and the atom is in lagrange mode, self.lagrange is used as the lagrange parameter, else an exception is raised.

The class atom’s lagrange_prox just returns the appropriate lagrange parameter for use by the subclasses.

Parameters

arg : np.ndarray(np.float)

Argument of the proximal map.

lipschitz : float

Coefficient in front of the quadratic.

lagrange : float (optional)

Lagrange factor in front of the seminorm. Defaults to self.lagrange.

Returns

Z : np.ndarray(np.float)

The proximal map of arg.

latexify(var=None, idx='')

Return a LaTeX representation of an object.

>>> import regreg.api as rr
>>> penalty = rr.l1norm(10, lagrange=0.9)
>>> penalty.latexify(var=r'\gamma') 
'\\lambda_{} \\|\\gamma\\|_1'
Parameters

var : string

Argument of the functions

idx : string

Optional subscript index.

Returns

L : string

A LaTeX representation of the atom.

classmethod linear(linear_operator, lagrange=None, diag=False, bound=None, quadratic=None, offset=None)
property linear_transform

The linear transform applied before a penalty is computed. Defaults to regreg.affine.identity

>>> from regreg.api import l1norm
>>> penalty = l1norm(30, lagrange=3.4)
>>> type(penalty.linear_transform)
<class 'regreg.affine.identity'>
nonsmooth_objective(arg, check_feasibility=False)

The nonsmooth objective function of the atom. Includes self.quadratic.objective(arg).

>>> import regreg.api as rr
>>> penalty = rr.l1norm(4, lagrange=2)
>>> penalty.nonsmooth_objective([3, 4, 5, 9])
42.0
>>> 2 * sum([3, 4, 5, 9])
42
Parameters

arg : np.ndarray(np.float)

Argument of the seminorm.

check_feasibility : bool

If True, then return np.inf if appropriate.

Returns

value : np.float

The seminorm of arg.

objective(x, check_feasibility=False)
objective_template = '{\\cal D}^{group sparse}(%(var)s)'
objective_vars = {'dualnormklass': 'supnorm', 'initargs': '(30,)', 'linear': 'D', 'normklass': 'l1norm', 'offset': '\\alpha', 'shape': 'p', 'var': '\\beta'}
property offset
proximal(quadratic, prox_control=None)

The proximal operator. If the atom is in Lagrange mode, this has the form

\[\beta^{\lambda}(\theta) = \text{argmin}_{\beta \in \mathbb{R}^{p}} \frac{L}{2} \|\theta-\beta\|^2_2 + \lambda h(\beta-\alpha) + \langle \beta, \eta \rangle\]

where \(\alpha\) is self.offset, \(\eta\) is quadratic.linear_term, \(\theta\) is quadratic.center and

\[h(\beta) = \sum_g w_g \|\beta[g]\|_2\]

If the atom is in bound mode, then this has the form

\[\beta^{\delta}(\theta) = \text{argmin}_{\beta \in \mathbb{R}^{p}} \frac{L}{2} \|\theta-\beta\|^2_2 + \langle \beta, \eta \rangle \ \text{s.t.} \ h(\beta - \alpha) \leq \delta\]
>>> import regreg.api as rr
>>> penalty = rr.l1norm(4, lagrange=2)
>>> Q = rr.identity_quadratic(1.5, [3, -4, -1, 1], 0, 0)
>>> penalty.proximal(Q) 
array([ 1.6666..., -2.6666..., -0.        ,  0.        ])
Parameters

quadratic : regreg.identity_quadratic.identity_quadratic

A quadratic added to the atom before minimizing.

prox_control : [None, dict]

This argument is ignored for seminorms, but otherwise is passed to regreg.algorithms.FISTA if the atom needs to be solved iteratively.

Returns

Z : np.ndarray(np.float)

The proximal map of the implied center of quadratic.

proximal_optimum(quadratic)
proximal_step(quadratic, prox_control=None)

Compute the proximal optimization

Parameters

prox_control: [None, dict]

If not None, then a dictionary of parameters for the prox procedure

property quadratic

Quadratic part of the object, instance of regreg.identity_quadratic.identity_quadratic.

seminorm(x, lagrange=None, check_feasibility=False)

Return \(\lambda \cdot {\cal D}^{group sparse}(\beta)\), where \(\lambda\) is lagrange. If check_feasibility is True, and seminorm is unbounded, will return np.inf if appropriate.

The class seminorm’s seminorm just returns the appropriate lagrange parameter for use by the subclasses.

set_bound(bound)

Set method of the bound property.

>>> import regreg.api as rr
>>> constraint = rr.group_lasso([1, 1, 2, 2, 2], bound=3.4) 
>>> constraint.bound
3.4
>>> constraint.bound = 2.3
>>> constraint.bound
2.3
>>> penalty = rr.group_lasso([1, 1, 2, 2, 2], lagrange=2.3)
>>> penalty.bound = 3.4 
Traceback (most recent call last):
...
AttributeError: atom is in lagrange mode
set_lagrange(lagrange)

Set method of the lagrange property.

>>> import regreg.api as rr
>>> penalty = rr.group_lasso([1, 1, 2, 2, 2], lagrange=3.4)
>>> penalty.lagrange
3.4
>>> penalty.lagrange = 2.3
>>> penalty.lagrange
2.3
>>> constraint = rr.group_lasso([1, 1, 2, 2, 2], bound=3.4)
>>> constraint.lagrange = 3.4 
Traceback (most recent call last):
...
AttributeError: atom is in bound mode
set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

set_weight(group, weight)

Set a group’s weight after initialization.

classmethod shift(offset, lagrange=None, diag=False, bound=None, quadratic=None)
smooth_objective(x, mode='both', check_feasibility=False)

The zero function.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)
terms(arg)

Return the args that are summed in computing the seminorm.

>>> import regreg.api as rr
>>> groups = [1,1,2,2,2]
>>> penalty = rr.group_lasso(groups, lagrange=1.)
>>> arg = [2,4,5,3,4]
>>> penalty.terms(arg) 
[6.3245..., 12.2474...]
>>> penalty.seminorm(arg) 
18.5720...
>>> np.sqrt((2**2 + 4**2)*2), np.sqrt((5**2 + 3**2 + 4**2) * 3.) 
(6.3245..., 12.2474...)
>>> np.sqrt((2**2 + 4**2)*2) + np.sqrt((5**2 + 3**2 + 4**2) * 3.) 
18.5720...
tol = 1e-05

Function

regreg.atoms.sparse_group_lasso.inside_set(atom, point)

Is the point in the dual ball?

If the atom is the primal (necessarily in lagrange form), we check whether point is in the dual ball (i.e. the one determining the norm.

If the atom is a dual (necessarily in bound form), we just check if we project onto the same point.