smooth.losses

Module: smooth.losses

Inheritance diagram for regreg.smooth.losses:

digraph inheritance84209d2f27 { rankdir=LR; size="8.0, 12.0"; "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.smooth" [URL="regreg.problems.composite.html#regreg.problems.composite.smooth",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 has 0 as "]; "problems.composite.composite" -> "problems.composite.smooth" [arrowsize=0.5,style="setlinewidth(0.5)"]; "regreg.smooth.smooth_atom" [URL="regreg.smooth.html#regreg.smooth.smooth_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 for representing a smooth function and its gradient"]; "problems.composite.smooth" -> "regreg.smooth.smooth_atom" [arrowsize=0.5,style="setlinewidth(0.5)"]; "smooth.losses.huberized_svm" [URL="#regreg.smooth.losses.huberized_svm",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top"]; "regreg.smooth.smooth_atom" -> "smooth.losses.huberized_svm" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

A module for commonly used losses that are not in regreg.smooth.glm. Only current example is Huberized SVM.

huberized_svm

class regreg.smooth.losses.huberized_svm(X, labels, smoothing_parameter, coef=1.0, offset=None, quadratic=None, initial=None)

Bases: regreg.smooth.smooth_atom

__init__(X, labels, smoothing_parameter, coef=1.0, offset=None, quadratic=None, initial=None)

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

classmethod affine(linear_operator, offset, coef=1, diag=False, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

apply_offset(x)

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

property conjugate
get_conjugate()
get_lipschitz()
get_offset()
get_quadratic()

Get the quadratic part of the composite.

latexify(var=None, idx='')
classmethod linear(linear_operator, coef=1, diag=False, offset=None, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

property lipschitz
nonsmooth_objective(x, check_feasibility=False)
objective(x, check_feasibility=False)
objective_template = '\\ell^{\\text{Huber SVM}}\\left(%(var)s\\right)'
objective_vars = {'coef': 'C', 'offset': '\\alpha+', 'shape': 'p', 'var': '\\beta'}
property offset
proximal(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.

scale(obj, copy=False)
set_lipschitz(value)
set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

classmethod shift(offset, coef=1, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

smooth_objective(beta, mode='both', check_feasibility=False)
Parameters

beta : ndarray

The current parameter values.

mode : str

One of [‘func’, ‘grad’, ‘both’].

check_feasibility : bool

If True, return np.inf when point is not feasible, i.e. when beta is not in the domain.

Returns

If mode is ‘func’ returns just the objective value

at beta, else if mode is ‘grad’ returns the gradient

else returns both.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

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