Skip to content

Instantly share code, notes, and snippets.

View rupenp's full-sized avatar
💭
not self-satisfied

Rupen rupenp

💭
not self-satisfied
View GitHub Profile
@rupenp
rupenp / tupperware.py
Created May 6, 2016 01:53 — forked from floer32/tupperware.py
recursively convert nested dicts to nested namedtuples, giving you something like immutable object literals
from UserDict import IterableUserDict
import collections
__author__ = 'github.com/hangtwenty'
def tupperware(mapping):
""" Convert mappings to 'tupperwares' recursively.
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
@rupenp
rupenp / mlp.py
Created June 5, 2013 02:04 — forked from amueller/mlp.py
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