Skip to content

Instantly share code, notes, and snippets.

View amueller's full-sized avatar

Andreas Mueller amueller

View GitHub Profile
@amueller
amueller / colors_curves.png
Last active April 20, 2024 01:38
random color palette using halton codes
colors_curves.png
@amueller
amueller / gist:1351047
Created November 9, 2011 10:23
sklearn precomputed kernel example
from sklearn.datasets import load_digits
from sklearn.svm import SVC
from sklearn.utils import shuffle
from sklearn.metrics import zero_one_score
import numpy as np
digits = load_digits()
X, y = shuffle(digits.data, digits.target)
X_train, X_test = X[:1000, :], X[1000:, :]
@amueller
amueller / filterbank.py
Created July 17, 2012 14:23
Filterbank responses for low level vision
##########################################################################
# Maximum Response filterbank from
# http://www.robots.ox.ac.uk/~vgg/research/texclass/filters.html
# based on several edge and bar filters.
# Adapted to Python by Andreas Mueller amueller@ais.uni-bonn.de
# Share and enjoy
#
import numpy as np
import matplotlib.pyplot as plt
@amueller
amueller / Diagram1.dia
Last active August 18, 2022 05:03
Machine learning cheat sheet diagram svg and dia file
@amueller
amueller / dpgmm_sampler.py
Created March 10, 2012 13:31
Nonparametric Gaussian mixture model data sampling
import numpy as np
import scipy.stats
class ChineseRestaurantProcess(object):
def __init__(self, alpha):
self.alpha = alpha
self.customers = []
def sample(self, n_samples=1):
samples = []
@amueller
amueller / digits_video.py
Created October 5, 2012 19:13
Visualization of iris and digits datasets via random projections
# (c) 2012 Andreas Mueller amueller@ais.uni-bonn.de
# License: BSD 2-Clause
#
# See my blog for details: http://peekaboo-vision.blogspot.com
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@amueller
amueller / mnist_kernel_approx.py
Last active December 11, 2020 14:31
Comparing Nystroem and Fourier feature based kernel approximation on MNIST
# Standard scientific Python imports
import pylab as pl
import numpy as np
from time import time
# Import datasets, classifiers and performance metrics
from sklearn import datasets, svm, pipeline
from sklearn.kernel_approximation import (RBFSampler,
Nystroem)
from sklearn.utils import shuffle
@amueller
amueller / abomination.py
Created July 28, 2016 21:02
binary operators on all estimators
from sklearn.base import BaseEstimator
def piper(self, other):
from sklearn.pipeline import make_pipeline, Pipeline
if isinstance(self, Pipeline):
steps = ([estimator for (name, estimator) in self.steps] + [other])
return make_pipeline(*steps)
else:
return make_pipeline(self, other)
@amueller
amueller / mlp.py
Created March 17, 2012 15:59
Multi-Layer Perceptron for scikit-learn with SGD in Python
import numpy as np
import warnings
from itertools import cycle, izip
from sklearn.utils import gen_even_slices
from sklearn.utils import shuffle
from sklearn.base import BaseEstimator
from sklearn.base import ClassifierMixin
from sklearn.preprocessing import LabelBinarizer