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
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:, :] |
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
########################################################################## | |
# 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 |
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 scipy.stats | |
class ChineseRestaurantProcess(object): | |
def __init__(self, alpha): | |
self.alpha = alpha | |
self.customers = [] | |
def sample(self, n_samples=1): | |
samples = [] |
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
# (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.
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
# 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 |
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
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) |
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 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 |
NewerOlder