Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bhtucker
bhtucker / prediction_variance.ipynb
Created November 12, 2016 22:21
Demo of some ideas for detecting noisy groups of observations in a multiclass classification setting
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bhtucker
bhtucker / close_commit_test.py
Last active February 24, 2022 20:00
Psycopg2 context manager demo: contextmanagers for closing and committing don't play well together without autocommit
import psycopg2
from contextlib import closing
"""
Demonstrate that contextmanagers for closing and committing don't play well together without autocommit
Only the noclosing function can run without error
"""
@bhtucker
bhtucker / upsert.py
Last active April 3, 2024 15:56
A demonstration of Postgres upserts in SQLAlchemy
"""
Upsert gist
Requires at least postgres 9.5 and sqlalchemy 1.1
Initial state:
[]
Initial upsert:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bhtucker
bhtucker / diehard_puzzle_solver.py
Created June 23, 2016 18:58
Strongly solving a puzzle through breadth-first search
"""
Implementation of the example from https://inst.eecs.berkeley.edu/~cs61c/fa14/projs/02/
"""
import operator
class Puzzle(object):
"""General game representation"""
def solution(self):
return Position(0)
@bhtucker
bhtucker / hogwild_logistic_reg.py
Last active April 23, 2019 22:51
Use a Hogwild-inspired algorithm to learn logistic regression over a sample dataset in parallel
"""
Demo of using Hogwild algorthim for parallel learning with shared memory
Uses sklearn's LogisticRegression for accuracy comparison
Output
('initial accuracy:', 0.45333333333333331)
worker 25974 score 0.93
worker 25975 score 0.92
worker 25976 score 0.88
worker 25974 score 0.94
@bhtucker
bhtucker / Three Python Plotting Options.ipynb
Created June 21, 2016 19:03
An intro to some easy, interactive data visualization tools
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bhtucker
bhtucker / ladders.sql
Created June 1, 2016 15:10
Materialized view for debate league ladder rankings
create materialized view ladder as (
with
match_points as (
select
case ... end as aff_points,
case ... end as neg_points,
aff_id,
neg_id
),
@bhtucker
bhtucker / PyMC3_demo.ipynb
Created May 6, 2016 20:43
Notebook used during RC Data Science Fridays talk (5/6/2016)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.