Matplotlib subplots with row titles

I’ve had to google for this enough times now to know I should just write a function. Sharing it here in case it saves others time. The code is a riff on matplotlib.pyplot.subplots() with an additional argument for...

Read More

Realtime Chart in d3.js

Recently I was interested in making a realtime chart in d3 and had a hard time finding a simple tutorial on how to do it. This post is the tutorial I wish I was able to find.

This post will...

Read More

Python Debugging: How to use pdb.pm()

Python’s debugger, pdb, is a great tool and one of my favorite uses of pdb is pdb.pm(). This post shows how to use pdb.pm() by working through an example of a buggy implementation of mergesort.

...
Read More

Cluster a Correlation Matrix (in python)

Below is a function to rearrange variables in a correlation matrix (either pandas.DataFrame or numpy.ndarray) to group highly correlated variables near each other.

It turns a correlation matrix that looks like:

Correlation matrix before grouping

Into one...

Read More

Scikit-learn Tree Design

Scikit-learn has a well designed, extensible implementation of decision trees. The design pays dividends for techniques that rely on decision trees such as random forest. Overall, the design is a great example of thoughtfully designed machine learning code and is...

Read More

Understanding Stochastic Gradient Descent

Until recently, I thought of stochastic gradient descent as gradient descent… with a little bit of randomness. However, when I first looked up the details of stochastic gradient descent I was confused how it could possibly work. This post is...

Read More

Narrow language features; the case for avoiding reduce

A narrow language feature leaves little ambiguity to the intent of the code. Therefore, an experienced reader can selectively skip details of the expression without loss of understanding. In contrast, a reader is forced to carefully inspect an expression that...

Read More

Exploring backoff

Back off is the amount of time to wait before retrying a failed action. There are many choices for how to back off, including constant backoff (wait 10 seconds, then try again), random backoff (wait x seconds, where x is...

Read More

Error Handling with Clojure Async

If you are reading this, there is a good chance an Exception was thrown in one of your async blocks and something unexpected happened. If you are using at least Clojure 1.6.0, your exception printed to stderr and the go...

Read More