An example of FastICA with Scikit-Learn

Using the same dataset, we can now test the performance of the ICA. However, in this case, as explained, we need to zero-center and whiten the dataset, but fortunately these preprocessing steps are done by the Scikit-Learn implementation (if the parameter whiten=True is omitted).

To perform the ICA on the MNIST dataset, we're going to instantiate the  FastICA class, passing the arguments n_components=64 and the maximum number of iterations max_iter=5000. It's also possible to specify which function will be used to approximate the negentropy; however, the default is log cosh(x), which is normally a good choice:

from sklearn.decomposition import FastICAfastica = FastICA(n_components=64, max_iter=5000, ...

Get Mastering Machine Learning Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.