Skip to content

Instantly share code, notes, and snippets.

View joseph-allen's full-sized avatar

Joseph Allen joseph-allen

View GitHub Profile
@joseph-allen
joseph-allen / times.js
Last active August 9, 2016 12:48
converts TV times to useful times
fs = require('fs');
moment = require('moment');
var dates = []
fs.readFile('times.js', 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
/**
* @fileoverview Rule to flag use of _.cloneDeep
* @author Joseph Allen
*/
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = function(context) {
{
"cells": [
{
"cell_type": "code",
"execution_count": 518,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
#!/bin/bash
echo -n "GitHub User: "
read USER
echo -n "GitHub Password: "
read -s PASS
echo ""
echo -n "GitHub Repo (e.g. foo/bar): "
import pandas as pd
import sys
import itertools
def permute(df):
columns = [df[column] for column in list(df)]
uniq_columns = [columns[x].unique() for x in range(0, len(columns))]
return pd.DataFrame(list(itertools.product(*uniq_columns)),
@joseph-allen
joseph-allen / gist:f50306ba76d5c539feeb281384702a80
Created September 28, 2017 11:46
exporting jupyter notebook without input
jupyter nbconvert --to pdf Report.ipynb --TemplateExporter.exclude_input=True
@pytest.fixture(params=[('input', 'expected')])
def get_input(request):
return request.param
@pytest.fixture
def get_function_result(get_input):
return test_function(get_input[0])
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
def plot_histograms(df, variables, n_rows, n_cols):
fig = plt.figure(figsize=(16, 12))
for i, var_name in enumerate(variables):
ax = fig.add_subplot(n_rows, n_cols, i+1)
@joseph-allen
joseph-allen / useful imports
Created December 29, 2017 14:18
Useful imports for a jupyter investigation
# Ignore warnings
import warnings
warnings.filterwarnings('ignore')
# Handle table-like data and matrices
import numpy as np
import pandas as pd
# Modelling Algorithms
from sklearn.tree import DecisionTreeClassifier
@joseph-allen
joseph-allen / outlier_detection
Created December 29, 2017 14:22
Tukey method outlier detection
import numpy as np
from collections import Counter
def detect_outliers(df, n, features):
"""
Takes a dataframe df of features and returns a list of the indices
corresponding to the observations containing more than n outliers according
to the Tukey method.
"""