This file contains 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 |
This file contains 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 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 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 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 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
#!/usr/bin/env python2.6 | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
# | |
# Written (W) 2013 Christian Widmer | |
# Copyright (C) 2013 Max-Planck-Society, MSKCC, TU-Berlin | |
""" |
This file contains 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 copy | |
import random | |
import pylab | |
import scipy.cluster.hierarchy as sch | |
def create_linkage_matrix(num_tasks): | |
""" | |
create stack of matrices for |
This file contains 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
#!/usr/bin/env python2.5 | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
# | |
# Written (W) 2010-2013 Christian Widmer | |
# Copyright (C) 2010-2013 Max-Planck-Society, TU-Berlin, MSKCC | |
""" |
This file contains 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 pylab | |
import numpy | |
def show_seqs(seqs): | |
""" | |
plot color coded training sequences | |
""" | |
This file contains 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 random | |
def coshuffle(*args): | |
""" | |
will shuffle target_list and apply | |
same permutation to other lists | |
>>> helper.coshuffle([2, 1, 3], [4, 2, 8], [6, 3, 12]) | |
([5, 3, 2, 1, 4], [5, 3, 2, 1, 4], [5, 3, 2, 1, 4]) |
NewerOlder