Perform Principal Component Analysis using the NIPALS algorithm.
This algorithm is particularly useful if you have more variables than
observations, or in general when the number of variables is huge and
calculating a full covariance matrix may be infeasible. It's also more
efficient of the standard PCANode if you expect the number of significant
principal components to be a small. In this case setting output_dim to be
a certain fraction of the total variance, say 90%, may be of some help.
Reference
Reference for NIPALS (Nonlinear Iterative Partial Least Squares):
Wold, H.
Nonlinear estimation by iterative least squares procedures.
in David, F. (Editor), Research Papers in Statistics, Wiley,
New York, pp 411-444 (1966).
More information about Principal Component Analysis*, a.k.a. discrete
Karhunen-Loeve transform can be found among others in
I.T. Jolliffe, Principal Component Analysis, Springer-Verlag (1986).
Original code contributed by:
Michael Schmuker, Susanne Lezius, and Farzad Farkhooi (2008).
|
__init__(self,
input_dim=None,
output_dim=None,
dtype=None,
conv=1e-08,
max_it=100000)
Initializes an object of type 'NIPALSNode'. |
|
|
|
_stop_training(self,
debug=False)
Concatenate the collected data in a single array. |
|
|
|
_train(self,
x)
Collect all input data in a list. |
|
|
|
stop_training(self,
debug=False)
Concatenate the collected data in a single array. |
|
|
|
train(self,
x)
Collect all input data in a list. |
|
|
Inherited from unreachable.newobject :
__long__ ,
__native__ ,
__nonzero__ ,
__unicode__ ,
next
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
tuple
|
_adjust_output_dim(self)
This function is used if the output dimensions is smaller than the input
dimension (so only the larger eigenvectors have to be kept). If required it
sets the output dim. |
|
|
|
|
numpy.ndarray
|
_execute(self,
x,
n=None)
Project the input on the first 'n' principal components. |
|
|
numpy.ndarray
|
_inverse(self,
y,
n=None)
Project data from the output to the input space using the
first 'n' components. |
|
|
|
|
numpy.ndarray
|
execute(self,
x,
n=None)
Project the input on the first 'n' principal components. |
|
|
float
|
get_explained_variance(self)
The explained variance is the fraction of the original variance
that can be explained by self._output_dim PCA components. If for
example output_dim has been set to 0.95, the explained variance could
be something like 0.958... |
|
|
numpy.ndarray
|
|
numpy.ndarray
|
get_recmatrix(self,
transposed=1)
Returns the the back-projection matrix
(i.e. the reconstruction matrix). |
|
|
numpy.ndarray
|
inverse(self,
y,
n=None)
Project data from the output to the input space using the
first 'n' components. |
|
|
|
|
|
__call__(self,
x,
*args,
**kwargs)
Calling an instance of Node is equivalent to calling
its execute method. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_refcast(self,
x)
Helper function to cast arrays to the internal dtype. |
|
|
|
|
|
|
|
copy(self,
protocol=None)
Return a deep copy of the node. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_training(self)
Return True if the node is in the training phase,
False otherwise. |
|
|
|
save(self,
filename,
protocol=-1)
Save a pickled serialization of the node to filename .
If filename is None, return a string. |
|
|
|
set_dtype(self,
t)
Set internal structures' dtype. |
|
|
|
|
|
|