Package parsimony :: Package functions :: Module penalties :: Class LInf
[hide private]
[frames] | no frames]

Class LInf

source code

               object --+        
                        |        
      properties.Function --+    
                            |    
    properties.AtomicFunction --+
                                |
                   object --+   |
                            |   |
           properties.Penalty --+
                                |
                   object --+   |
                            |   |
        properties.Constraint --+
                                |
                   object --+   |
                            |   |
  properties.ProximalOperator --+
                                |
                   object --+   |
                            |   |
properties.ProjectionOperator --+
                                |
                               LInf

The proximal operator of the L-infinity function

    f(x) = l * (||x||_inf - c),

where ||x||_inf is the L-infinity loss function. The constrainted version
has the form

    ||x||_inf <= c.

Parameters
----------
l : Non-negative float. The Lagrange multiplier, or regularisation
        constant, of the function.

c : Float. The limit of the constraint. The function is feasible if
        ||x||_inf <= c. The default value is c=0, i.e. the default is a
        regularisation formulation.

penalty_start : Non-negative integer. The number of columns, variables
        etc., to be exempt from penalisation. Equivalently, the first index
        to be penalised. Default is 0, all columns are included.

Instance Methods [hide private]
 
__init__(self, l=1.0, c=0.0, penalty_start=0)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
f(self, x)
Function value.
source code
 
prox(self, x, factor=1.0, **kwargs)
The corresponding proximal operator.
source code
 
proj(self, x)
The corresponding projection operator.
source code
 
feasible(self, x)
Feasibility of the constraint.
source code

Inherited from properties.Function: get_params, reset, set_params

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  __abstractmethods__ = frozenset([])

Inherited from properties.AtomicFunction: __metaclass__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, l=1.0, c=0.0, penalty_start=0)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

f(self, x)

source code 
Function value.

From the interface "Function".

Parameters
----------
x : Numpy array. The point at which to evaluate the function.

Example
-------
>>> import numpy as np
>>> from parsimony.functions.penalties import LInf
>>> import parsimony.utils.maths as maths
>>>
>>> np.random.seed(42)
>>> x = np.random.rand(10, 1)
>>> linf = LInf(l=1.1)
>>> linf.f(x) - 1.1 * maths.normInf(x)
0.0

Overrides: properties.Function.f

prox(self, x, factor=1.0, **kwargs)

source code 
The corresponding proximal operator.

From the interface "ProximalOperator".

Examples
--------
>>> import numpy as np
>>> from parsimony.functions.penalties import LInf
>>> import parsimony.utils.maths as maths
>>>
>>> np.random.seed(42)
>>> x = np.random.rand(10, 1)
>>> linf = LInf(l=1.45673045, c=0.5)
>>> linf_prox = linf.prox(x)
>>> linf_prox
array([[ 0.37454012],
       [ 0.5       ],
       [ 0.5       ],
       [ 0.5       ],
       [ 0.15601864],
       [ 0.15599452],
       [ 0.05808361],
       [ 0.5       ],
       [ 0.5       ],
       [ 0.5       ]])
>>> linf_proj = linf.proj(x)
>>> linf_proj
array([[ 0.37454012],
       [ 0.5       ],
       [ 0.5       ],
       [ 0.5       ],
       [ 0.15601864],
       [ 0.15599452],
       [ 0.05808361],
       [ 0.5       ],
       [ 0.5       ],
       [ 0.5       ]])
>>> np.linalg.norm(linf_prox - linf_proj)
7.2392821740411278e-09

Overrides: properties.ProximalOperator.prox

proj(self, x)

source code 
The corresponding projection operator.

From the interface "ProjectionOperator".

Examples
--------
>>> import numpy as np
>>> from parsimony.functions.penalties import LInf
>>>
>>> np.random.seed(42)
>>> x = np.random.rand(10, 1) * 2.0 - 1.0
>>> linf = LInf(c=0.618)
>>> linf.proj(x)
array([[-0.25091976],
       [ 0.618     ],
       [ 0.46398788],
       [ 0.19731697],
       [-0.618     ],
       [-0.618     ],
       [-0.618     ],
       [ 0.618     ],
       [ 0.20223002],
       [ 0.41614516]])

Overrides: properties.ProjectionOperator.proj

feasible(self, x)

source code 
Feasibility of the constraint.

From the interface "Constraint".

Parameters
----------
x : Numpy array. The variable to check for feasibility.

Examples
--------
>>> import numpy as np
>>> from parsimony.functions.penalties import LInf
>>>
>>> np.random.seed(42)
>>> x = np.random.rand(10, 1) * 2.0 - 1.0
>>> linf = LInf(c=0.618)
>>> linf.feasible(x)
False
>>> linf.feasible(linf.proj(x))
True

Overrides: properties.Constraint.feasible