[SciPy-user] mdp question
Ramon Crehuet
rcsqtc at iiqab.csic.es
Thu Sep 29 09:49:56 CDT 2005
Hi all,
I am using mdp to perform a PCA on some (dummy) variables. I can get the
principal components but I do not know how to get the "explained
variance" or change the number of output components. Here is my input:
import mdp
from scipy import array
x=array([[1.51, -2.10, 1.91],
[-2.10, 0.45, -1.25],
[1.59, -0.51, 0.50],
[0.45, -0.93, 1.51],
[0.04, -0.49,-0.09],
[-0.78, 1.89,-1.55],
[-0.62,0.00, -0.42]])
pca=mdp.nodes.PCANode()
pca.train(x)
pca.stop_training()
mat=pca.get_projmatrix()
# works fine.
x=pca.execute(x,1)
#works fine, too.
print pca.get_explained_variance()
# This gives "None"
pca.set_output_dim(1)
# and this raises an exception:
Traceback (most recent call last):
File "/home/ramon/python/pca.py", line 21, in -toplevel-
pca.set_output_dim(1)
File "/usr/lib/python2.3/site-packages/mdp/nodes/pca_nodes.py", line
32, in set_output_dim
raise TrainingFinishedException, errstr
NameError: global name 'TrainingFinishedException' is not defined
Could someone tell me what I am doing wrong?
By the way, does anybody know of an implementation of the partial least
squares algorithm?
Thanks for your help.
Ramon
More information about the SciPy-user
mailing list