Skip to content

Instantly share code, notes, and snippets.

View psychemedia's full-sized avatar

Tony Hirst psychemedia

View GitHub Profile
@mhawksey
mhawksey / gist:105a4f6e5e2dcdba69b8c5e2868da373
Created May 5, 2016 21:46
Accumulated enrollment and daily growth of FutureLearn data
# Extension of https://github.com/psychemedia/futurelearnStatsSketches/blob/master/notebooks/FutureLearn%20Stats%20Recipes.ipynb
def plot_cumulativeCount(df, group, groupset, index, title, start, end):
plt.rc("figure", figsize=(15, 10))
df=df[df[group].isin(groupset)]
df=df.reset_index().set_index(index)
df.sort_index(inplace=True)
df=date_limiter(df, start, end)
df['Total enrollments']=range(len(df))
@mhawksey
mhawksey / gist:c6dd723a79d8b5ca646ceb8827f67242
Created May 5, 2016 08:44
Calendar Heatmap of FutureLearn steps
#generate a calendar heatmap of step visits
# http://stackoverflow.com/a/32492179
# Extension of https://github.com/psychemedia/futurelearnStatsSketches/blob/master/notebooks/FutureLearn%20Stats%20Recipes.ipynb
import datetime as dt
def generate_data():
num = 100
data = np.random.randint(0, 20, num)
start = pd.to_datetime(COURSE_START_DATE)
@mhawksey
mhawksey / gist:99ea405a8aac79f4bc0becfbc950479b
Last active May 4, 2016 20:27
FutureLearn Stats Recipes Enrollment Summary
# Enrollment summary graph
# Extension of https://github.com/psychemedia/futurelearnStatsSketches/blob/master/notebooks/FutureLearn%20Stats%20Recipes.ipynb
import matplotlib.ticker as tkr
cat = ['Enrolled learners', 'Visited at least one step', 'Completed at least one step', 'Commented at least once']
count = [len(enrolled_learners),
len(enrolled_learners.intersection(stepstart_learners)),
len(enrolled_learners.intersection(stepcomplete_learners)),
len(commenting_learners)
@calvingiles
calvingiles / data-science-environment-fig.yml
Last active May 26, 2016 07:24
fig.yml for setting up a data science environment
notebooks:
command: echo created
image: busybox
volumes:
- "~/Google Drive/notebooks:/notebooks"
data:
command: echo created
image: busybox
volumes:
- "~/Google Drive/data:/data"
@jkeirstead
jkeirstead / epsrc-fellowships-funnel.r
Last active June 11, 2019 15:33
A funnel plot analysis of EPSRC Fellowship success rates
# Analysis of EPSRC fellowship success rates
# 18 November 2013
# James Keirstead
##' Calculates the bounds for a funnel plot
##'
##' Calculates the upper and lower confidence interval limits for use
##' in a funnel plot. Assumes a binomial discrete distribution with a
##' probability of success theta.
##'
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite