Skip to content

Instantly share code, notes, and snippets.

Tyler Neylon tylerneylon

Block or report user

Report or block tylerneylon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tylerneylon / prec_95_example.ipynb
Created May 30, 2019
Example of visualizing and extracting classifier cutoff values to meet certain precision-recall objectives.
View prec_95_example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Have 1d array-likes y_true and y_pred.
# y_true is expected to be 0/1,
# and y_pred is expected to have floats in [0, 1].
# I learned how to do this from here:
from sklearn.metrics import average_precision_score
from sklearn.metrics import precision_recall_curve
tylerneylon / pre-commit
Last active Nov 24, 2019
git pre-commit hook to help support github-based code reviews of Jupyter notebooks in Python.
View pre-commit
# Convert all new Jupyter notebooks to straight Python files for easier code
# reviews.
for file in $(git diff --cached --name-only); do
if [[ $file == *.ipynb ]]; then
jupyter nbconvert --to script $file
git add ${file%.*}.py
tylerneylon /
Last active Dec 12, 2019
A simple read-write lock implementation in Python.
# -*- coding: utf-8 -*-
A class to implement read-write locks on top of the standard threading
This is implemented with two mutexes (threading.Lock instances) as per this
wikipedia pseudocode:
tylerneylon /
Created Jan 12, 2018
Quick reference on how to work with pre-trained word2vec vectors in Python.
# This file shows one way to work with word2vec data in Python.
# Setup:
# 1. Install gensim:
# pip install gensim
tylerneylon / cow.c
Created Sep 4, 2017
An example Lua module written in C.
View cow.c
// A Lua module written in C.
// This module enables terminal-based ASCII art
// of a loquacious bovine nature.
#include <stdio.h>
#include <stdlib.h>
#include "lua.h"
tylerneylon / lua_interp.c
Last active Sep 4, 2017
A bare-bones Lua interpreter, in C.
View lua_interp.c
// A bare-bones Lua interpreter, in C.
#include <stdio.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
int main() {
tylerneylon /
Created Mar 26, 2017
20 shortish lines that do something fun.
import itertools, os, sys
it, chars = 20, '.-=*x#X'
w = int(os.popen('tput cols').read())
h = int(os.popen('tput lines').read()) - 1
x_max, y_max = float(w) / (2.0 * h) * 1.2, 1.2
for j in itertools.count(1):
tylerneylon /
Last active May 4, 2019
A function to load numpy arrays from the MNIST data files.
""" A function that can read MNIST's idx file format into numpy arrays.
The MNIST data files can be downloaded from here:
This relies on the fact that the MNIST dataset consistently uses
unsigned char types with their data segments.
tylerneylon /
Created Jul 26, 2016
Terminal-based color table
# A bash function to print out a table of
# colors supported by your terminal.
colortable() {
tput setaf 0
for i in $(seq 0 $(tput colors)); do
tput setab $i
printf %4d $i
You can’t perform that action at this time.