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 matplotlib.pyplot as plt | |
from sklearn.svm import LinearSVC | |
from sklearn.cross_validation import ShuffleSplit | |
from sklearn.grid_search import GridSearchCV | |
from sklearn import datasets | |
n_samples = 100 |
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 | |
from sklearn.grid_search import GridSearchCV | |
from sklearn.cross_validation import StratifiedKFold | |
from sklearn.datasets import load_iris | |
from sklearn.svm import LinearSVC | |
iris = load_iris() | |
X, y = iris.data, iris.target | |
cv = StratifiedKFold(y, 3) |
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 check_grad(f, fprime, x0): | |
eps = 1e-5 | |
approx = np.zeros(len(x0)) | |
for i in xrange(len(x0)): | |
x0_ = x0.copy() | |
x0_[i] += eps | |
approx[i] = (f(x0_) - f(x0)) / eps | |
return np.linalg.norm(approx.ravel() - fprime(x0).ravel()) | |
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 make_node(p, name=1): | |
if p == 0: | |
return [name] | |
return [name, make_node(p - 1, 10 * name + 0), | |
make_node(p - 1, 10 * name + 1)] | |
def depth_first(p): | |
print(p[0]) | |
if len(p) == 3: |
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
====================================================================== | |
FAIL: test_texture.TestLBP.test_default | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest | |
self.test(*self.arg) | |
File "/home/andy/checkout/scikits.image/skimage/feature/tests/test_texture.py", line 163, in test_default | |
np.testing.assert_array_equal(lbp, ref) | |
File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 707, in assert_array_equal | |
verbose=verbose, header='Arrays are not equal') |
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 | |
from scipy import sparse | |
from sklearn import svm | |
from nose.tools import assert_raises | |
X = np.array([[-2, -1], [-1, -1], [-1, -2], [1, 1], [1, 2], [2, 1]]) | |
X_sp = sparse.lil_matrix(X) | |
Y = [1, 1, 1, 2, 2, 2] | |
sp = svm.sparse.SVC(C=1, kernel=lambda x, y: x * y.T, probability=True) |
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 | |
from sklearn.feature_selection import chi2 | |
data = np.load("values.npy") | |
labels = np.load("labels.npy") | |
print(chi2(data, labels)) |
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
blub |
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.utils.testing import all_estimators | |
import numpy as np | |
all_objects = [] | |
for C in all_estimators(): | |
try: | |
all_objects.append(C[1]()) | |
except: | |
pass | |
params = [c.get_params().keys() for c in all_objects] |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.