Skip to content

Instantly share code, notes, and snippets.

View cbowdon's full-sized avatar

Chris Bowdon cbowdon

View GitHub Profile
@cbowdon
cbowdon / sanity.md
Created April 27, 2023 09:57
ML classifier sanity checklist

SAVE YOUR SANITY

Things I know but need a checklist to ensure I address them systematically.

  1. Dataset is balanced - dev, train and test. Do you have approx. balanced classes in each?
  2. Is each dataset distinct? Have you checked for duplicates within and across datasets?
  3. Is the data shuffled?
  4. Spot check the data. Are the classifications consistent and in line with the objective?
  5. Score the model before training. Is its accuracy close to random?
  6. Train the simplest available model (no pretrained vectors) on a small subset of data (overfit). Does its loss improve? Does its accuracy improve to something better than random?
@cbowdon
cbowdon / intercepting-proxy.sh
Created January 4, 2019 17:20
Poor man's intercepting proxy
#!/usr/bin/env bash
# Thanks to https://blog.hawkhost.com/2009/12/12/using-netcat-as-an-intercepting-proxy/
server=${1:-localhost}
localport=${2:-8080}
remoteport=${3:-$localport}
pipe=intercepting-proxy.pipe
@cbowdon
cbowdon / frankenstein_chapter_5.dot
Created December 31, 2018 18:31
Graph of words for Frankenstein Chapter 5
graph "graph" {
"fit[NN]" -- "monster[NN]" ["weight"="1"]
"presence[NN]" -- "recollection[NN]" ["weight"="1"]
"presence[NN]" -- "home[NN]" ["weight"="1"]
"presence[NN]" -- "scene[NNS]" ["weight"="1"]
"presence[NN]" -- "Clerval[NNP]" ["weight"="1"]
"presence[NN]" -- "father[NN]" ["weight"="1"]
"presence[NN]" -- "Elizabeth[NNP]" ["weight"="1"]
"presence[NN]" -- "delight[NN]" ["weight"="1"]
"presence[NN]" -- "nothing[NN]" ["weight"="1"]
@cbowdon
cbowdon / org-element-path-api.el
Created January 14, 2016 22:06
Some lisp helper functions for doing XPATH-like queries on org-mode files
(defun org-element-path (path list-of-asts)
"Select all contents of LIST-OF-ASTS matching PATH"
(message (format "%s" path))
(defun --subpath-match (p)
(org-element--select-contents (car p) list-of-asts))
(if (cadr path)
(org-element-path (cdr path) (--subpath-match path))
(--subpath-match path)))
(defun --flatten (list-of-lists)
@cbowdon
cbowdon / template.el
Created November 1, 2015 20:11
Macro to add string interpolation to Emacs Lisp
(defmacro template (text)
"Expand text like \"Hello <<name>>\" to (format \"Hello %s\" name)."
(let ((pattern "<<\\(.*?\\)>>"))
;; The regexp matches anything between delimiters, non-greedily
(with-temp-buffer
(save-excursion (insert text))
(let ((matches '()))
(while (re-search-forward pattern nil t)
(push (match-string 1) matches)
(replace-match "%s" t t))