Skip to content

Instantly share code, notes, and snippets.

@dengemann
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dengemann/9091092 to your computer and use it in GitHub Desktop.
Save dengemann/9091092 to your computer and use it in GitHub Desktop.
# Author: Denis A. Engemann <d.engemann@fz-juelich.de>
#
# License: BSD (3-clause)
""" Profile FastICA options
Dependencies
------------
scikit-learn
https://github.com/fabianp/memory_profiler
Usage
-----
mprof run --python run_fast_ica.py
mprof plot
"""
import numpy as np
n_samples = 1e6/4
n_features = 250
rng = np.random.RandomState(42)
W = rng.random_sample([n_features, n_features])
X = rng.random_sample([n_samples, n_features])
print 'estimated data size in memory'
print '%i MB' % (X.size * X.itemsize / 1e6)
print '%s' % X.dtype
from sklearn.decomposition import FastICA
with profile.timestamp('FastICA-SVD-false'):
est = FastICA(n_components=50, whiten=True, svd_decorr=False)
est.fit(X)
with profile.timestamp('FastICA-SVD-true'):
est = FastICA(n_components=50, whiten=True, svd_decorr=True)
est.fit(X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment