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.base import TransformerMixin, BaseEstimator | |
class StandardTransformer(BaseEstimator, TransformerMixin): | |
def __init__(self, variables=[], ignore=[]): | |
self.variables = variables | |
self.ignore = ignore | |
self.transform_idx = np.asarray([True if i not in self.ignore | |
else False for i in self.variables]) |
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 os | |
import calendar | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.ticker import FixedLocator, FixedFormatter | |
import pandas as pd | |
import seaborn as sns | |
to_colors = lambda x : x/255. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 pymc import Gamma, Poisson, Normal, MCMC, deterministic | |
import numpy as np | |
dta = dict(T=73, Nsubj=430, eps=0.0, t=[1, 21, 85, 128, 129, 148, 178, 204, | |
206, 210, 211, 212, 225, 238, 241, | |
248, 259, 273, 275, 281, 286, 289, | |
301, 302, 303, 304, 313, 317, 323, | |
344, 345, 349, 350, 351, 355, 356, | |
359, 364, 385, 386, 389, 390, 391, | |
392, 394, 395, 396, 397, 398, 399, |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
In file included from /home/skipper/.local/lib/python3.3/site-packages/numpy/core/include/numpy/ndarraytypes.h:1761:0, | |
from /home/skipper/.local/lib/python3.3/site-packages/numpy/core/include/numpy/ndarrayobject.h:17, | |
from /home/skipper/.local/lib/python3.3/site-packages/numpy/core/include/numpy/arrayobject.h:4, | |
from mwe.c:346: | |
/home/skipper/.local/lib/python3.3/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp] | |
#warning "Using deprecated NumPy API, disable it by " \ | |
^ | |
In file included from /usr/include/python3.3m/pytime.h:6:0, | |
from /usr/include/python3.3m/Python.h:65, | |
from mwe.c:16: |
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
N = 2*10**7 | |
chunk_size = 100000 | |
farr1 = 'scratch/arr1' | |
farr2 = 'scratch/arr2' | |
arr1 = np.memmap(farr1, dtype='uint8', mode='w+', shape=(N, 4)) | |
arr2 = np.memmap(farr2, dtype='uint8', mode='w+', shape=(N, 4)) | |
for i in xrange(0, N, chunk_size): |
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 urllib2 import urlopen | |
from itertools import chain | |
def scan(url, sep=" ", skiprows=0): | |
f = urlopen(url).readlines()[skiprows:] | |
return map(float, chain(*map(lambda x : x.strip().split(sep), f))) | |
if __name__ == "__main__": | |
url = "http://robjhyndman.com/tsdldata/hurst/precip1.dat" | |
scan(url, 1) |
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 logging | |
for i in range(5): | |
for j in range(10, 15): | |
logger = logging.getLogger("log_{}_{}.log".format(i, j)) | |
handler = logging.FileHandler("log_{}_{}.log".format(i, j)) | |
logger.setLevel(logging.INFO) | |
logger.addHandler(handler) | |
logger.info("I'm on this loop") |
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 28 columns, instead of 11 in line 9.
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
Origin,Destination,Data,Oi,Dj,Dij,Offset,beta,OrigAT11,OrigAT12,OrigAT13,OrigAT21,OrigAT22,OrigAT31,OrigAT32,OrigAT33,OrigAT34,DestAT11,DestAT12,DestAT13,DestAT21,DestAT22,DestAT31,DestAT32,DestAT33,DestAT34,Oi2007,Dj2007 | |
AT11,AT11,0,4016,5146,9.999999999999994e-301,9.999999999999994e-301,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4320,5452 | |
AT11,AT12,1131,4016,25741,103.00184499999999,1.0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,4320,27169 | |
AT11,AT13,1887,4016,26980,84.204666,1.0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,4320,28710 | |
AT11,AT21,69,4016,4117,220.811933,1.0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,4320,4354 | |
AT11,AT22,738,4016,8634,132.00748000000002,1.0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,4320,9069 | |
AT11,AT31,98,4016,8193,214.51181400000002,1.0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,4320,8577 | |
AT11,AT32,31,4016,4902,246.933305,1.0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,4320,4963 | |
AT11,AT33,43,4016,3952,390.85611,1.0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,4320,3923 | |
AT11,AT34,19,4016,1910,505.08953899999995,1.0,1,0,0,0 |