Skip to content

Instantly share code, notes, and snippets.

View daveliepmann's full-sized avatar

Dave Liepmann daveliepmann

View GitHub Profile
@daveliepmann
daveliepmann / application.markdown
Last active May 25, 2016 17:30
Implementing Sugar & James’ paper, "Finding the number of clusters in a data set: An information theoretic approach" in Clojure — Part 2

Implementing the k-means jump method: Part Two

After implementing Sugar & James' jump method and exploring its application to Fisher's iris data in Part One of this series, we're now ready to apply the jumps-in-distortions test to some other sample data sets. Pure Clojure source here.

Remember these functions from earlier? We'll be using them again.

(defn assoc-distortions
  "Given a number `transformation-power-y` and a seq of maps
@daveliepmann
daveliepmann / application.clj
Last active July 12, 2017 14:12
Clojure source for Part 2 of "Implementing the k-means jump method" — see https://gist.github.com/daveliepmann/3df6599128edfc24ea02267ec6b047b5
(ns jump-sugar-james.application
(:require [incanter.core :as i]
[incanter.stats :as incs]
[incanter.charts :as incc]
[clj-ml.clusterers :as mlc]
[clj-ml.data :as mld]
[clojure.string :as s]))
;;;; We'll need some functions from earlier.
@daveliepmann
daveliepmann / curveball.markdown
Last active May 15, 2016 14:47
Implementing Sugar & James’ paper, "Finding the number of clusters in a data set: An information theoretic approach" in Clojure — Part 3

Implementing the k-means jump method: Part Three

After implementing Sugar & James jump method and applying it straightforwardly to a few data sets, we're ready to throw it a few curveballs. This will demonstrate both its robustness and some necessary aspects of setting it up for success.

Again we need some functions we built in part one and part two. Feel free to skip this part if you don't need the review and you're not following along with a REPL. If you are following along in the REPL, here's the full Clojure source.

(def iris (i/to-matrix (incd/get-dataset :iris)))
@daveliepmann
daveliepmann / curveball.clj
Last active July 12, 2017 14:11
Clojure source for part 3 of "Implementing the k-means jump method" — see https://gist.github.com/daveliepmann/67dde9f05df12af134ac344b7a2886d9
(ns jump-sugar-james.curveball
(:require [incanter.core :as i]
[incanter.stats :as incs]
[incanter.charts :as incc]
[incanter.datasets :as incd]
[clj-ml.clusterers :as mlc]
[clj-ml.data :as mld]))
;;;; We'll need some functions from earlier.
@daveliepmann
daveliepmann / bootstrapping.markdown
Created May 27, 2016 08:11
Implementing Sugar & James’ paper, "Finding the number of clusters in a data set: An information theoretic approach" in Clojure — Part 4

Implementing the k-means jump method: Part Four

This fourth and final part of our exploration into the jump method wraps things up by following a basic application of the technique through to a search for results we can be confident in.

We'll reuse functions from rest of the series (Part One, Part Two, Part Three). You'll also want the original paper handy to refer back to their charts.

First, we're going to return to several prior data sets:

;;;; Fernseheturm
(def base
(layer (position 35 90 (colorize "grey" (circle 25)))
(position 34 0 (colorize "grey" (rectangle 4 300)))
(position 29 108 (colorize "grey" (rectangle 12 222)))
(position 29 50 (colorize "grey" (rectangle 12 16)))
(position 15 315 (colorize "grey" (triangle 40)))
(position 26 125 (colorize "grey" (rectangle 18 16)))
(position 24 182 (colorize "grey" (rectangle 5 158)))
;; # A whirlwind tour of Maria.cloud
;; ### 🔺 🔷 🔴 🔶 🔵 🔻
;; The first thing you should do is draw something:
(circle 50)
;; we provide an extensive picture language:
(layer
@daveliepmann
daveliepmann / gallery.cljs
Last active August 14, 2017 11:56
Gallery of example expressions, for Maria
@daveliepmann
daveliepmann / clojurebridge_02_data_structures.cljs
Last active August 5, 2017 07:40
ClojureBridge Berlin curriculum 2: Data Structures
;; # Data Structures
;;
;; So far, we've dealt with discrete pieces of data: one number, one
;; string, one value. When programming, it is more often the case that
;; you want to work with groups of data.
;;
;; Clojure has great facilities for working with these groups, or
;; *collections*, of data. Not only does it provide four different types
;; of collections, but it also provides a uniform way to use all of these
;; # One-Rep-Maximum Calculator
;; People who strength train often want to predict the maximum weight they could lift for one repetition. This is because actually making a maximal attempt is tiring, slightly risky, and difficult to repeat. Let's see how to guess our "1RM" using sub-maximal attempts.
;; If you need to re-evaluate one of the code blocks below, put your cursor in it and press `Control-Shift-Enter` (`Command-Shift-Enter` on Mac).
;; ## Equations
;; There are many equations used to predict one-repetition maximum based on the greatest weight lifted for two to ten reps. All are unavoidably inexact. One popular method for determining your 1RM comes from Baechle, Earle, and Wathen (2000):