Skip to content

Instantly share code, notes, and snippets.

@ashenfad
Last active Aug 7, 2017
Embed
What would you like to do?
Convert a 2d collection into an anomaly detector
(ns detector
(:require (bigml.api [core :as api]
[source :as source]
[dataset :as dataset]
[anomaly-detector :as anomaly-detector]
[anomaly-score :as anomaly-score])
(clojure.data [csv :as csv])))
(defn data->detector [data]
(-> (source/create data)
(api/get-final)
(dataset/create)
(api/get-final)
(anomaly-detector/create :forest_size 64)
(api/get-final)
(anomaly-score/detector)))
;; A tiny example...
(def my-detector
(-> (slurp "https://goo.gl/79KsJ4")
(csv/read-csv)
(data->detector)))
(println (my-detector [0.5 0.45 0.4 0.44 0.01]))
;; 0.3936344773676654
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment