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 datetime | |
class Timer: | |
def __init__(self, string=None): | |
self.string = string | |
def __enter__(self): | |
self.t1 = datetime.datetime.now() | |
def __exit__(self, exc_type, exc_value, traceback): |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
font: 10px sans-serif; | |
} | |
.axis path, | |
.axis line { |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
font: 10px sans-serif; | |
} | |
.axis path, | |
.axis line { |
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 | |
# Create a random dataset | |
rng = np.random.RandomState(1) | |
X = np.sort(5 * rng.rand(80, 1), axis=0) | |
y = np.sin(X).ravel() | |
y += .2 * (0.5 - rng.rand(80)) | |
# Fit regression model | |
from sklearn.tree import DecisionTreeRegressor |
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 collections import namedtuple | |
# Create a random dataset | |
rng = np.random.RandomState(42) | |
N_points = 100 | |
X = np.sort(5 * rng.rand(N_points, 1), axis=0) | |
y = np.sin(X).ravel() | |
y += .4 * (0.5 - rng.rand(N_points)) | |
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 collections import namedtuple | |
# Create a random dataset | |
rng = np.random.RandomState(42) | |
N_points = 10000 | |
X = np.sort(5 * rng.rand(N_points, 1), axis=0) | |
y = np.sin(X).ravel() | |
y += .4 * (0.5 - rng.rand(N_points)) | |
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
#!/usr/bin/env python | |
import sys | |
n_rows = int(sys.argv[1]) | |
data = map(lambda x: [], xrange(n_rows)) | |
for k, line in enumerate(sys.stdin): | |
data[k % n_rows] += [line.rstrip()] |
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
# To run this command: | |
# curl https://gist.githubusercontent.com/tianhuil/0aa9b265f55413dc7198/raw > setup_digitalocean.sh | |
# . setup_digitalocean.sh | |
# Update sudo apt-get | |
sudo apt-get update | |
# Installing scientific Python | |
sudo apt-get -y install --fix-missing build-essential python-dev python-numpy python-setuptools python-scipy libatlas-dev | |
sudo apt-get -y install --fix-missing build-essential python-sklearn |
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
# if you need to install virtualenv | |
# pip install virtualenv | |
# in the folder | |
virtualenv venv | |
. venv/bin/activate | |
# to deactivate | |
# deactivate |
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
# Instaling Ubuntu | |
# http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDH4/latest/CDH4-Quick-Start/cdh4qs_topic_3_2.html | |
# While, we're at it, let's install the JDK ... | |
echo "y" | sudo apt-get install openjdk-6-jdk | |
# ... and Yelp's mrjob | |
pip install mrjob | |
# Install maven |
OlderNewer