This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dual_pca(X, max_num_pcs): | |
""" | |
assuming N << D (X.shape[0] << X.shape[1]), | |
we first compute the kernel matrix K = XX^T, perform an | |
eigendecomposition and subsequently reconstruct | |
truncated principle components | |
""" | |
K = X.dot(X.T) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
snippet to time different indexing strategies | |
based on: | |
http://wesmckinney.com/blog/?p=215 | |
http://stackoverflow.com/questions/11800075/faster-numpy-fancy-indexing-and-reduction/11813040#11813040 | |
http://stackoverflow.com/questions/14386822/fast-numpy-fancy-indexing?rq=1 | |
""" | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
cache linear algebra (or any other) operations | |
based on hashes of input arguments | |
""" | |
import numpy.linalg as la | |
from sklearn.external import joblib | |
mem = joblib.Memory(cachedir=cachedir, verbose=True, compress=True) | |
#mem.clear() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import time | |
# generate data | |
X = np.random.randn(1000, 10000) | |
t0 = time.time() | |
K = X.dot(X.T) + 1e-9*np.eye(X.shape[0]) | |
tK = time.time() - t0 | |
print "tK:", tK |
OlderNewer