Skip to content

Instantly share code, notes, and snippets.

@cwharland
cwharland / dupe_packages.sh
Created September 15, 2016 03:25
Find all packages installed by both conda and pip
conda list | tr -s ' ' | cut -d ' ' -f1 | uniq -c | awk '$1>1'
@cwharland
cwharland / skflow_linear_regression_test.py
Created January 17, 2016 23:23
Example of skflow's inability to recover weights?
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LinearRegression
import skflow
import pytest
class TestLinearRegression:
def setup_class(self):
'''Simple linear model with a tiny amount of noise'''
rng = np.random.RandomState(67)
@cwharland
cwharland / studs.py
Created August 31, 2015 22:19
Studs Terkel Interviews
from bs4 import BeautifulSoup as bs
import urllib2
import re
import wget
# Where do you want to download the files?
path = '~/studs_terkel/%s'
# Page with all the mp3 links
url = 'http://conversations.studsterkel.org/htimes.php'
@cwharland
cwharland / confusion_to_array.py
Created April 27, 2015 03:36
Create Fake Confusion Matrix Arrays
import pandas as pd
import numpy as np
from sklearn.metrics import confusion_matrix
labels = ['N', 'L', 'R', 'A', 'P', 'V']
df = pd.DataFrame([
[1971, 19, 1, 8, 0, 1],
[16, 1940, 2, 23, 9, 10],
[8, 3, 181, 87, 0, 11],
[2, 25, 159, 1786, 16, 12],
@cwharland
cwharland / for_tdhopper.py
Created April 9, 2015 19:33
Pandas Series Title
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
pd.Series(np.random.normal(1,10, size=1000)).hist()
plt.title('Sweet')
# Flatten a nested array or list
[item for sublist in l for item in sublist]
@cwharland
cwharland / gist:47d15286b10bd200057e
Last active August 29, 2015 14:13
Seaborn matplotlib rc adjustments for base16-tomorrow-dark
custom_style = {'axes.labelcolor': 'white',
'axes.linewidth': 2,
'xtick.color': 'white',
'ytick.color': 'white',
'lines.color': 'white',
'patch.edgecolor': 'white',
'text.color': 'white',
'axes.facecolor': '#1d1f21',
'axes.edgecolor': 'white',
'axes.labelcolor': 'white',
@cwharland
cwharland / 0_reuse_code.js
Created April 3, 2014 01:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console