Package parsimony :: Package algorithms :: Module nipals :: Class SparsePLSR
[hide private]
[frames] | no frames]

Class SparsePLSR

source code

          object --+        
                   |        
 bases.BaseAlgorithm --+    
                       |    
 bases.ImplicitAlgorithm --+
                           |
              object --+   |
                       |   |
bases.IterativeAlgorithm --+
                           |
                          SparsePLSR

A NIPALS implementation for Sparse PLS regresison.

Parameters
----------
l : List or tuple of two non-negative floats. The Lagrange multipliers, or
        regularisation constants, for the X and Y blocks, respectively.

penalise_y : Bool. Whether or not to penalise the Y block as well.

max_iter : Non-negative integer. Maximum allowed number of iterations.
        Default is 200.

eps : Positive float. The tolerance used in the stopping criterion.

Examples
--------
>>> from parsimony.algorithms.nipals import SparsePLSR
>>> import numpy as np
>>> np.random.seed(42)
>>>
>>> X = np.random.rand(10, 10)
>>> Y = np.random.rand(10, 5)
>>> w = np.random.rand(10, 1)
>>> c = np.random.rand(5, 1)
>>> plsr = SparsePLSR(l=[4.0, 5.0])
>>> w, c = plsr.run([X, Y], [w, c])
>>> w
array([[ 0.32012726],
       [ 0.31873833],
       [ 0.15539258],
       [ 0.64271827],
       [ 0.23337738],
       [ 0.54819589],
       [ 0.        ],
       [ 0.06088551],
       [ 0.        ],
       [ 0.        ]])
>>> c
array([[ 0.1463623 ],
       [ 0.66483154],
       [ 0.4666803 ],
       [ 0.        ],
       [ 0.5646119 ]])

Instance Methods [hide private]
 
__init__(self, l=[0.0, 0.0], penalise_y=True, max_iter=200, eps=5e-08, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
run(self, XY, wc=None)
A NIPALS implementation for sparse PLS regresison.
source code

Inherited from bases.BaseAlgorithm: get_params, set_params

Inherited from bases.IterativeAlgorithm: iter_reset

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

Static Methods [hide private]

Inherited from bases.BaseAlgorithm: check_compatibility

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

Inherited from bases.ImplicitAlgorithm: __metaclass__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, l=[0.0, 0.0], penalise_y=True, max_iter=200, eps=5e-08, **kwargs)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

run(self, XY, wc=None)

source code 
A NIPALS implementation for sparse PLS regresison.

Parameters
----------
XY : List of two numpy arrays. XY[0] is n-by-p and XY[1] is n-by-q. The
        independent and dependent variables.

wc : List of numpy array. The start vectors.

Returns
-------
w : Numpy array, p-by-1. The weight vector of X.

c : Numpy array, q-by-1. The weight vector of Y.

Overrides: bases.ImplicitAlgorithm.run