Skip to content

Instantly share code, notes, and snippets.

@adamwlev
adamwlev / NaturalCubicSplines.ipynb
Last active January 7, 2020 20:37
Natural Cubic Splines
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@adamwlev
adamwlev / affine_transformation.py
Last active May 16, 2017 04:54
Affine Transformation
import numpy as np
def produce_transformation(tuples,tuples_t):
"""
Given points in some 2d space, and points in a transformed
2d space, produces function to tranform one space to other.
tuples : points in original space (list of x,y tuples)
tuples_t : corresponding points in transformed space (")
"""
@adamwlev
adamwlev / .block
Created January 4, 2017 05:51
BayesApp
license: gpl-3.0
@adamwlev
adamwlev / monitor.py
Last active April 25, 2017 15:13
Make a Monitor Function to Train a Gradient Booster from Sklearn with automated early stopping
## Makes a monitor where the mean of last x oob improvements
## are used to determine early stopping. This can be ammended
## to any stopping criteria one sees as fit - consecutive x
## negatives, more negatives than positives in last x, etc.
def make_monitor(running_mean_len):
def monitor(i,self,args):
if np.mean(self.oob_improvement_[max(0,i-running_mean_len+1):i+1])<0:
return True
else:
@adamwlev
adamwlev / TheRightAndWrongWaytoDoCrossValidation.ipynb
Last active September 22, 2016 19:35
Adapted from *Elements of Statistical Learning* Friedman, Tibshirani, and Hastie
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.