Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Cédric LACZNY <cedric.laczny@un...>  20121210 18:03:20

Hi, I wanted to know if there is a way to project data using FastICA onto only _one_ (or a certain number in general) dimension? The PCANode class has the possibility to specify the number of dimensions in the execute() command via the "n" argument, but I am missing this for the FastICA. >>> x = np.random.random((100, 25)) # 25 variables, 100 observations >>> model = mdp.nodes.PCANode() >>> y = pca.execute(x,1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: <lambda>() takes exactly 2 arguments (3 given) >>> y = model.execute(x,1) >>> np.size(y,0) 100 >>> # NOW we want to use FastICA ... >>> model = mdp.nodes.FastICANode() >>> y = model.execute(x,1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: <lambda>() takes exactly 2 arguments (3 given) Is there a way to effectively overwrite the output dimension? Using set_output_dim() seems not to work for me. >>> model = mdp.nodes.FastICANode() >>> model.train(x) >>> model.stop_training() >>> model FastICANode(input_dim=25, output_dim=25, dtype='float64') >>> model.set_output_dim(1) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/clusterusers/claczny/lib/python2.7/sitepackages/MDP3.3py2.7.egg/mdp/signal_node.py", line 336, in set_output_dim raise InconsistentDimException(msg) mdp.signal_node.InconsistentDimException: Output dim are set already (25) (1 given)! Thank you. With best regards, Cedric Laczny Cedric Laczny, PhD Student UNIVERSITÉ DU LUXEMBOURG LUXEMBOURG CENTRE FOR SYSTEMS BIOMEDICINE Campus Belval  House of Biomedicine 7, avenue des HautsFourneaux L4362 EschsurAlzette T +352 46 66 44 6398 F +352 46 66 44 6949 cedric.laczny@... http://lcsb.uni.lu  This message is confidential and may contain privileged information. It is intended for the named recipient only. If you receive it in error please notify me and permanently delete the original message and any copies.  
From: Tiziano Zito <tiziano.zito@bc...>  20121211 09:58:04

Hi Cédric, > The PCANode class has the possibility to specify the number of > dimensions in the execute() command via the "n" argument, but I am > missing this for the FastICA. > [..] > >>> model = mdp.nodes.FastICANode() > >>> y = model.execute(x,1) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: <lambda>() takes exactly 2 arguments (3 given) The reason why this is not implemented is quite simple actually. The output components of FastICA do not have any inherent order. Component number 1 in one run could be component number 35 in the next run, given the very same input data. So when you write: y = model.execute(x,1) there is not guarantee of what you are going to get. If you *know* your components and just want to filter some data through one of them, you could just do: y = model.execute(x)[:,n] where n is the component you are looking for (starting from 0). > Is there a way to effectively overwrite the output dimension? > Using set_output_dim() seems not to work for me. > > >>> model = mdp.nodes.FastICANode() > >>> model.train(x) > >>> model.stop_training() > >>> model > FastICANode(input_dim=25, output_dim=25, dtype='float64') > >>> model.set_output_dim(1) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/home/clusterusers/claczny/lib/python2.7/sitepackages/MDP3.3py2.7.egg/mdp/signal_node.py", line 336, in set_output_dim > raise InconsistentDimException(msg) > mdp.signal_node.InconsistentDimException: Output dim are set already (25) (1 given)! That's not possible and would not help in your case. The output dimensionality of a FastICANode gets fixed as soon as you feed it with some data. Changing output_dim on the fly would break any flow using the node. Hope that helps, Tiziano 
From: Cédric LACZNY <cedric.laczny@un...>  20121211 11:09:58

Hi, thank you very much, that explains of course why this can't be done using MDPtoolkit. I was looking for a solution with ICA similar to projecting a given set of observations to the "1st" component, so in analogy to PCA, the direction with the highest variance among all the other directions. Of course, the math behind ICA is different then behind PCA and the "variance" aspect is just an arbitrary criterion (i.e. example) in my case. Searching for other existing solutions revealed scikitlearn which has the option to specify a certain number of components to be extracted also for FastICA (n_components). I have not yet tested it nor do I know if it does actually exactly what I desire to do. However, I was wondering why this is not possible in mdp? The explanation may be as simple as "we didn't see this as a requirement", which I would completely understand. In any case, I am curious to know more about it and maybe it is something to be thought of to be integrated, if (and that is a big if) the overall design of mdp is actually allowing it (which may indeed be another explanation for the absence of this functionality). So it is not about saying 'this is good or bad' but rather understanding why. Or maybe it is as simple as that scikitlearn does indeed something along your suggestion and could thus also be readily realized using mdp: > If you *know* your components and just want to filter some data > through one of them, you could just do: > > y = model.execute(x)[:,n] Thank you. Best, Cedric On 11 Dec 2012, at 10:16, Tiziano Zito wrote: > Hi Cédric, > >> The PCANode class has the possibility to specify the number of >> dimensions in the execute() command via the "n" argument, but I am >> missing this for the FastICA. >> [..] >>>>> model = mdp.nodes.FastICANode() >>>>> y = model.execute(x,1) >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> TypeError: <lambda>() takes exactly 2 arguments (3 given) > > The reason why this is not implemented is quite simple actually. The > output components of FastICA do not have any inherent order. > Component number 1 in one run could be component number 35 in the > next run, given the very same input data. So when you write: > > y = model.execute(x,1) > > there is not guarantee of what you are going to get. > > If you *know* your components and just want to filter some data > through one of them, you could just do: > > y = model.execute(x)[:,n] > > where n is the component you are looking for (starting from 0). > >> Is there a way to effectively overwrite the output dimension? >> Using set_output_dim() seems not to work for me. >> >>>>> model = mdp.nodes.FastICANode() >>>>> model.train(x) >>>>> model.stop_training() >>>>> model >> FastICANode(input_dim=25, output_dim=25, dtype='float64') >>>>> model.set_output_dim(1) >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> File "/home/clusterusers/claczny/lib/python2.7/sitepackages/MDP3.3py2.7.egg/mdp/signal_node.py", line 336, in set_output_dim >> raise InconsistentDimException(msg) >> mdp.signal_node.InconsistentDimException: Output dim are set already (25) (1 given)! > > That's not possible and would not help in your case. The output > dimensionality of a FastICANode gets fixed as soon as you feed it > with some data. Changing output_dim on the fly would break any flow > using the node. > > Hope that helps, > Tiziano > 
From: Tiziano Zito <tiziano.zito@bc...>  20121211 11:17:07

> I was looking for a solution with ICA similar to projecting a > given set of observations to the "1st" component, so in analogy to > PCA, the direction with the highest variance among all the other > directions. Of course, the math behind ICA is different then > behind PCA and the "variance" aspect is just an arbitrary > criterion (i.e. example) in my case. Note that all output components of FastICA are "white", i.e. they all have identical variance equal to 1. > Searching for other existing solutions revealed scikitlearn which > has the option to specify a certain number of components to be > extracted also for FastICA (n_components). I have not yet tested > it nor do I know if it does actually exactly what I desire to do. > However, I was wondering why this is not possible in mdp? sklearn is just using the n_components argument as a dimensionality reduction into the whitening step during preprocessing. You can obtain the very same result in MDP if you do: ica = mdp.nodes.FastICANode(white_comp=n) Just look at the docstring of the FastICANode object for more, and more and more, options. > The explanation may be as simple as "we didn't see this as a > requirement", which I would completely understand. In any case, I > am curious to know more about it and maybe it is something to be > thought of to be integrated, if (and that is a big if) the overall > design of mdp is actually allowing it (which may indeed be another > explanation for the absence of this functionality). So it is not > about saying 'this is good or bad' but rather understanding why. > Or maybe it is as simple as that scikitlearn does indeed > something along your suggestion and could thus also be readily > realized using mdp As explained above, this is not what n_components is doing in the sklearn. I think that what you want to do just does not make sense in the ICA model. In any case, if what you were looking for is how to reduce the dimensionality (using variance as a criterion) in the preprocessing, you can do it in MDP or in sklearn in a very similar way. Hope that helps, Tiziano 
Sign up for the SourceForge newsletter:
No, thanks