Skip to content

Commit

Permalink
OTH: added failing test for no eigenvalues left problem.
Browse files Browse the repository at this point in the history
When PCANode is set to use SVD and automatic dimensionality reduction
it may happen that after removing directions corresponding to
eigenvalues smaller than var_abs (1e-12 default), nothing is left.
This happens for example if the data is a matrix of (almost) zeros.
The error looks like this:
Traceback (most recent call last):
[...]
File ".../mdp/nodes/pca_nodes.py", line 220, in _stop_training
    d = d[ d / d.max() > self.var_rel ]
ValueError: zero-size array to ufunc.reduce without identity
  • Loading branch information
otizonaizit committed Jan 12, 2012
1 parent 8a64b7e commit b0810d7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mdp/test/test_PCANode.py
Expand Up @@ -225,3 +225,10 @@ def testPCANode_negative_eigenvalues():
pca.train(uniform((10,10)))
pca.stop_training()
assert pca.output_dim == 1, 'PCA did not remove non-positive eigenvalues!'

def test_PCANode_no_eigenvalues_left():
mat = numx.zeros((100,4), dtype='d')
pca = mdp.nodes.PCANode(svd=True, reduce=True)
pca.train(mat)
pca.stop_training()

0 comments on commit b0810d7

Please sign in to comment.