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 random | |
from joblib import Parallel, delayed | |
import time | |
def Example(c): | |
some_random_delay = int(2*random.random()*c) | |
time.sleep(some_random_delay) # let's pretend we're doing work | |
print some_random_delay | |
return some_random_delay |
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 __future__ import division | |
import numpy | |
from sklearn import hmm | |
""" | |
X is a numpy array with shape (#samples, #sensors). | |
X = [[sensor1(0), sensor2(0)], [sensor1(1), sensor2(1)], ..., [sensor1(T), sensor2(T)]] | |
nc = number of latent states (3 would imply three strata) |
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
# python 3.3: example of futures | |
import time | |
import concurrent.futures | |
def add(x, y): | |
time.sleep(2) | |
return x + y | |
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as queue: |
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
package main | |
import ( | |
"fmt" | |
"github.com/gorilla/mux" | |
"github.com/tristanwietsma/metastore" | |
"log" | |
"net/http" | |
) |
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
# OSCATS | |
FROM ubuntu | |
MAINTAINER Tristan Wietsma [email protected] | |
RUN apt-get update | |
RUN apt-get upgrade -y | |
RUN apt-get install -y build-essential | |
RUN apt-get install -y autoconf automake |
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 flask | |
import qrcode | |
import qrcode.image.svg | |
import qrcode.image.pil | |
app = flask.Flask(__name__) | |
class TextStream: | |
def __init__(self): |
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 rpy2.robjects as ro | |
import rpy2.robjects.numpy2ri as n2r | |
n2r.activate() | |
r = ro.r | |
r.library('glmnet') | |
# input files (for this example) need to have header and NO index column | |
X = np.loadtxt('./x.csv', dtype=float, delimiter=',', skiprows=1) |
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 __future__ import division | |
import numpy | |
import rpy2.robjects as ro | |
import rpy2.rlike.container as rlc | |
import rpy2.robjects.numpy2ri as numpy2ri | |
X = numpy.random.rand(100, 3) | |
_y = 0.25*X[:,0] + 0.7*X[:,1] - 0.45*X[:,2] |
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 | |
import pandas | |
df1 = pandas.DataFrame(numpy.random.randn(5,4), columns=list('ABCD')) | |
df2 = pandas.DataFrame(numpy.random.randn(5,4), columns=list('DEFG')) | |
print pandas.merge(df1, df2, on='D', how='outer') | |
# A B C D E F G | |
# 0 1.054809 -0.078626 -0.052766 0.463954 NaN NaN NaN |
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
# Python Data Science Environment | |
# | |
# VERSION 1.0 | |
# use ubuntu base image from dotCloud | |
FROM ubuntu | |
MAINTAINER Tristan Wietsma [email protected] | |
# update and upgrade repos | |
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list |