Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexey Brazhe abrazhe

View GitHub Profile
View Ullah's model.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abrazhe
abrazhe / gist:df8d2d788a507aa0d0e07ebd2ac2bcd8
Created May 10, 2017 — forked from hamishmorgan/gist:3342260
A quick demo of how to produce a loglog histogram plot of very large amounts of data, by using log-histogram bins.
View gist:df8d2d788a507aa0d0e07ebd2ac2bcd8
# A quick demo of how to produce a loglog histogram plot of very large
# amounts of data, by using log-histogram bins
import numpy as np
import matplotlib.pyplot as plt
import itertools as it
# We shall draw millions of samples from a Zipf distribution. Using linear
# bins this is too much data for a fast and attactive plot.
@abrazhe
abrazhe / fast_svd.py
Created May 4, 2017 — forked from alextp/fast_svd.py
Gunnar Martinsson's fast svd
View fast_svd.py
import numpy as np, numpy.linalg as linalg
def fast_svd(M, k):
p = k+5
Y = np.dot(M, np.random.normal(size=(M.shape[1],p)))
Q,r = linalg.qr(Y)
B = np.dot(Q.T,M)
Uhat, s, v = linalg.svd(B, full_matrices=False)
U = np.dot(Q, Uhat)
return U.T[:k].T, s[:k], v[:k]
View gist:ad0ff4b2dc3b9b33e9c6
import numpy as np
from scipy import linalg
from sklearn.utils import array2d, as_float_array
from sklearn.base import TransformerMixin, BaseEstimator
class ZCA(BaseEstimator, TransformerMixin):
def __init__(self, regularization=10**-5, copy=False):
self.regularization = regularization