Skip to content

Instantly share code, notes, and snippets.

View walterreade's full-sized avatar

Walter Reade walterreade

View GitHub Profile
@walterreade
walterreade / xgb_fscore
Created April 19, 2015 13:43
XGBoost Variable Importance
fscore = [ (v,k) for k,v in clf.get_fscore().iteritems() ]
fscore.sort(reverse=True)
@walterreade
walterreade / kaggle_lb_score.py
Last active August 29, 2015 14:21
Show the progression of a Kaggle leader board distribution over time
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
scores = pd.read_csv('liberty-mutual-group-property-inspection-prediction_public_leaderboard.csv')
scores['SubmissionDate'] = [time.date() for time in scores['SubmissionDate'].astype('datetime64[ns]')]
scores['SubmissionDate'] = [time for time in scores['SubmissionDate'].astype(str)]
plt.style.use('bmh')
colors = ['#348ABD', '#A60628', '#7A68A6', '#467821', '#D55E00',
'#CC79A7', '#56B4E9', '#009E73', '#F0E442', '#0072B2']
https://github.com/rasbt/matplotlib-gallery
@walterreade
walterreade / gist:2aa0879f140c94b00653
Last active October 20, 2015 01:13
Standard ML Imports
import pandas as pd
pd.set_option('display.mpl_style', 'default')
pd.set_option('display.width', 200)
pd.set_option('display.max_columns', 20)
pd.set_option('display.max_rows', 50)
pd.set_option('precision', 5)
import matplotlib.pyplot as plt
import seaborn as sns
@walterreade
walterreade / DefaultFormula.py
Created May 23, 2013 20:12
Default Radio Button
thisField.setValue(0)
@walterreade
walterreade / sparse_dummies.py
Last active January 16, 2016 22:56
Create Sparse Dummies
# http://www.dataiku.com/blog/2015/08/24/xgboost_and_dss.html
from pandas.core.categorical import Categorical
from scipy.sparse import csr_matrix
import numpy as np
def sparse_dummies(categorical_values):
categories = Categorical.from_array(categorical_values)
N = len(categorical_values)
row_numbers = np.arange(N, dtype=np.int)
ones = np.ones((N,))
from scipy import exp, log
from scipy.special import gammaln
def prob_unique(N, r):
""" If you have a set of N things to choose from, and take r samples,
the probability that all r samples are unique.
http://www.johndcook.com/blog/2016/01/30/general-birthday-problem
"""
return exp( gammaln(N+1) - gammaln(N-r+1) - r*log(N) )
@walterreade
walterreade / readme.md
Created April 15, 2016 10:41 — forked from baraldilorenzo/readme.md
VGG-16 pre-trained model for Keras

##VGG16 model for Keras

This is the Keras model of the 16-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman

tag = 'h1'
text 'This is a headline'
sentence = '<{0}>{1}</{0}>'.format(tag, text)
person = {'name': 'Jenn', 'age': 23}
sentence = 'My name is {0[name]} and I am {0[age]} years old.'.format(person)
# can do the same for attributes, e.g., {0.name}, or list {0[0]}
# You can just unpack a dictionary!
sentence = 'My name is {name} and I am {age} years old.'.format(**person)