Class SparsePLSRegression
source code
object --+
|
BaseEstimator --+
|
RegressionEstimator --+
|
SparsePLSRegression
Estimator for sparse PLS regression
f(w, c, X, Y) = -Cov(X.w, Y.c) + l.|w|_1 + k.|c|_1,
where Cov(., .) is the covariance and |.|_1 is the L1 norm.
Parameters
----------
l : List or tuple of two non-negative floats. The Lagrange multipliers, or
regularisation constants, for the X and Y blocks, respectively.
K : Positive integer. The number of components to compute.
algorithm : OR(ImplicitAlgorithm, ExplicitAlgorithm). The algorithm that
should be used. Should be one of:
1. SparsePLSR()
2. MultiblockFISTA(...)
Default is SparsePLSR(...).
algorithm_params : A dict. The dictionary algorithm_params contains
parameters that should be set in the algorithm. Passing
algorithm=MyAlgorithm(**params) is equivalent to passing
algorithm=MyAlgorithm() and algorithm_params=params. Default
is an empty dictionary.
start_vector : BaseStartVector. Generates the start vector that will be
used.
mean : Boolean. Whether or not to compute the means squared error or the
squared error. Default is True, compute the means squared error.
Examples
--------
>>> import parsimony.estimators as estimators
>>> import parsimony.algorithms.nipals as nipals
>>> import parsimony.algorithms.multiblock as multiblock
>>> import numpy as np
>>> np.random.seed(42)
>>>
>>> n, p = 16, 10
>>> X = np.random.rand(n, p)
>>> y = np.random.rand(n, 1)
>>> plsr = estimators.SparsePLSRegression(l=[3.0, 0.0], K=1,
... algorithm=nipals.SparsePLSR(),
... algorithm_params=dict(max_iter=100))
>>> error = plsr.fit(X, y).score(X, y)
>>> print plsr.W
[[ 0.37053417]
[ 0.54969643]
[ 0.29593809]
[ 0.2937247 ]
[ 0.49989677]
[ 0.0895912 ]
[ 0. ]
[ 0.35883331]
[ 0. ]
[ 0. ]]
>>> print plsr.C
[[ 0.32949094]]
>>> print "error = ", error
error = 0.0547513077301
|
__init__(self,
l,
K=2,
algorithm=None,
algorithm_params={ } ,
start_vector=start_vectors.RandomStartVector(),
unbiased=True,
mean=True)
x.__init__(...) initializes x; see help(type(x)) for signature |
source code
|
|
|
|
|
|
|
score(self,
X,
Y)
Returns the (mean) squared error of the estimator. |
source code
|
|
Inherited from RegressionEstimator :
predict
Inherited from BaseEstimator :
get_info ,
parameters ,
set_params
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
Inherited from object :
__class__
|
__init__(self,
l,
K=2,
algorithm=None,
algorithm_params={ } ,
start_vector=start_vectors.RandomStartVector(),
unbiased=True,
mean=True)
(Constructor)
| source code
|
x.__init__(...) initializes x; see help(type(x)) for signature
- Overrides:
object.__init__
- (inherited documentation)
|