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

Class RGCCAConstraint

source code

           object --+            
                    |            
  properties.Function --+        
                        |        
properties.AtomicFunction --+    
                            |    
               object --+   |    
                        |   |    
      properties.Gradient --+    
                            |    
               object --+   |    
                        |   |    
       properties.Penalty --+    
                            |    
               object --+   |    
                        |   |    
    properties.Constraint --+    
                            |    
          QuadraticConstraint --+
                                |
                   object --+   |
                            |   |
properties.ProjectionOperator --+
                                |
                               RGCCAConstraint

Represents the quadratic function

    f(x) = l * (x'(tau * I + ((1 - tau) / n) * X'X)x - c),

where tau is a given regularisation constant. The constrained version has
the form

    x'(tau * I + ((1 - tau) / n) * X'X)x <= 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'(tau * I + ((1 - tau) / n) * X'X)x <= c. The default value is
        c=0, i.e. the default is a regularisation formulation.

tau : Non-negative float. The regularisation constant.

X : Numpy array, n-by-p. The associated data matrix. The first
        penalty_start columns will be excluded.

unbiased : Boolean. Whether the sample variance should be unbiased or not.
        Default is True, i.e. unbiased.

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, tau=1.0, X=None, unbiased=True, penalty_start=0)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
reset(self)
Free any cached computations from previous use of this Function.
source code
 
f(self, beta)
Function value.
source code
 
grad(self, beta)
Gradient of the function.
source code
 
feasible(self, beta)
Feasibility of the constraint.
source code
 
proj(self, beta, **kwargs)
The projection operator corresponding to the function.
source code
 
_compute_value(self, beta)
Helper function to compute the function value.
source code

Inherited from properties.Function: get_params, set_params

Inherited from properties.Gradient: approx_grad

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

Class Variables [hide private]

Inherited from QuadraticConstraint: __abstractmethods__

Inherited from properties.AtomicFunction: __metaclass__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, l=1.0, c=0.0, tau=1.0, X=None, unbiased=True, penalty_start=0)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

reset(self)

source code 

Free any cached computations from previous use of this Function.

Overrides: properties.Function.reset
(inherited documentation)

f(self, beta)

source code 

Function value.

Overrides: properties.Function.f

grad(self, beta)

source code 

Gradient of the function.

From the interface "Gradient".

Overrides: properties.Gradient.grad

feasible(self, beta)

source code 

Feasibility of the constraint.

From the interface "Constraint".

Overrides: properties.Constraint.feasible

proj(self, beta, **kwargs)

source code 
The projection operator corresponding to the function.

From the interface "ProjectionOperator".

Examples
--------
>>> import parsimony.functions.penalties as penalties
>>> import numpy as np
>>> np.random.seed(42)
>>>
>>> X = np.random.randn(10, 10)
>>> x = np.random.randn(10, 1)
>>> L2 = penalties.RGCCAConstraint(c=1.0, tau=1.0, X=X, unbiased=True)
>>> L2.f(x)
5.7906381220390024
>>> y = L2.proj(x)
>>> abs(L2.f(y)) <= 2.0 * consts.FLOAT_EPSILON
True
>>> np.linalg.norm(y)
0.99999999999999989

Overrides: properties.ProjectionOperator.proj

_compute_value(self, beta)

source code 

Helper function to compute the function value.

Note that beta must already be sliced!