This file contains hidden or 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 UserDict import IterableUserDict | |
| import collections | |
| __author__ = 'github.com/hangtwenty' | |
| def tupperware(mapping): | |
| """ Convert mappings to 'tupperwares' recursively. |
This file contains hidden or 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 math import sqrt | |
| phi = (1 + sqrt(5))/2 | |
| resphi = 2 - phi | |
| # a and b are the current bounds; the minimum is between them. | |
| # c is the center pointer pushed slightly left towards a | |
| def goldenSectionSearch(f, a, c, b, absolutePrecision): | |
| if abs(a - b) < absolutePrecision: | |
| return (a + b)/2 | |
| # Create a new possible center, in the area between c and b, pushed against c |
This file contains hidden or 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 |