Skip to content

Instantly share code, notes, and snippets.

@defndaines
Last active December 29, 2016 19:17
Show Gist options
  • Select an option

  • Save defndaines/bd7ac86a20db80bdc42f15ef37fa10ad to your computer and use it in GitHub Desktop.

Select an option

Save defndaines/bd7ac86a20db80bdc42f15ef37fa10ad to your computer and use it in GitHub Desktop.
Area Under Curve [AUC] reduce function
(defn iter
"Area Under Curve [AUC] reduce function.
The element is a vector of three elements: the ID of the model,
whether the classifier example is positive (pos),
and the probabilistic value (f).
The accumulator tracks six values, aggregated area, the last f value (f'),
negative examples (fp and fp'), and positive examples (tp and tp')."
[[area f' fp fp' tp tp'] [_ pos f]]
(if (= f' f)
[area
f'
(if pos fp (inc fp))
fp'
(if pos (inc tp) tp)
tp']
;; else
[(+ area (trap-area fp fp' tp tp'))
f
(if pos fp (inc fp))
fp
(if pos (inc tp) tp)
tp]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment