Skip to content

Instantly share code, notes, and snippets.

View springcoil's full-sized avatar

Peadar Coyle springcoil

View GitHub Profile
@springcoil
springcoil / Bayesian_Model_2.py
Last active August 29, 2015 14:21
A Bayesian model for myself to debug - PyData Berlin
df_avg = pd.DataFrame({'avg_att': atts.stats()['mean'],
'avg_def': defs.stats()['mean']},
index=teams.team.values)
df_avg = pd.merge(df_avg, df_observed, left_index=True, right_on='team', how='left')
fig, ax = plt.subplots(figsize=(8,6))
for outcome in ['winner', 'triple_crown', 'wooden_spooon', '']:
ax.plot(df_avg.avg_att[df_avg.QR == outcome],
df_avg.avg_def[df_avg.QR == outcome], 'o', label=outcome)
@springcoil
springcoil / bayesian_model3.py
Created May 15, 2015 12:38
Another Bayesian_Model which needs edited
df_hpd = pd.DataFrame(atts.stats()['95% HPD interval'],
columns=['hpd_low', 'hpd_high'],
index=teams.team.values)
df_median = pd.DataFrame(atts.stats()['quantiles'][50],
columns=['hpd_median'],
index=teams.team.values)
df_hpd = df_hpd.join(df_median)
df_hpd['relative_lower'] = df_hpd.hpd_median - df_hpd.hpd_low
df_hpd['relative_upper'] = df_hpd.hpd_high - df_hpd.hpd_median
df_hpd = df_hpd.sort_index(by='hpd_median')
docker-machine create \
--driver amazonec2 \
--amazonec2-access-key $ACCESS_KEY \
--amazonec2-secret-key $SECRET_KEY \
--amazonec2-vpc-id $VPC \
--amazonec2-security-group $SECURITY_GROUP \
--amazonec2-instance-type "m4.2xlarge" \
--amazonec2-root-size 20 \
--amazonec2-request-spot-instance \
--amazonec2-spot-price 0.20 \
@springcoil
springcoil / machinecreate.sh
Created July 19, 2015 11:42
Influenced by Trent Hauck
LC_ALL=C docker-machine create \
--driver amazonec2 \
--amazonec2-access-key $AWS_ACCESS_KEY_ID \
--amazonec2-secret-key $AWS_SECRET_ACCESS_KEY \
--amazonec2-region "eu-west-1" \
--amazonec2-vpc-id $VPC \
--amazonec2-instance-type "m4.2xlarge" \
--amazonec2-root-size 20 \
--amazonec2-request-spot-instance \
--amazonec2-spot-price 0.20 \
@springcoil
springcoil / basic_income_monte_carlo.py
Last active August 29, 2015 14:25 — forked from stucchio/basic_income_monte_carlo.py
Monte carlo simulation of basic income/basic job calculations, from blog.
from pylab import *
from scipy.stats import *
num_adults = 227e6
basic_income = 7.25*40*50
labor_force = 154e6
disabled_adults = 21e6
current_wealth_transfers = 3369e9
def jk_rowling(num_non_workers):
@springcoil
springcoil / assert_frames_equal.ipynb
Created October 5, 2015 15:44 — forked from jiffyclub/assert_frames_equal.ipynb
Example of a function to compare two DataFrames independent of row/column ordering and with handling of null values.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@springcoil
springcoil / gist:3231352
Created August 1, 2012 22:41 — forked from swannodette/gist:3217582
sudoku_compact.clj
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
(defn init [vars hints]
@springcoil
springcoil / FremontBridge.ipynb
Created October 20, 2015 20:53 — forked from jakevdp/FremontBridge.ipynb
Fremont Bike Counts 2015
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file has been truncated, but you can view the full file.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Reproducibility from the start"
]
},
{
@springcoil
springcoil / numba_test.py
Created October 26, 2015 17:07 — forked from jhemann/numba_test.py
Testing numba's autojit decorator on simple code for matrix factorization.
# -*- coding: utf-8 -*-
#!/usr/bin/python
#
# Modified example of Albert Au Yeung's on matrix factorization:
# http://www.quuxlabs.com/blog/2010/09/matrix-factorization-a-simple-tutorial-and-implementation-in-python/#source-code
import numpy as np
from numba.decorators import autojit, jit