Skip to content

Instantly share code, notes, and snippets.

@ashenfad
Last active August 7, 2017 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashenfad/31f1055d81f0432d305232fd71c19f6b to your computer and use it in GitHub Desktop.
Save ashenfad/31f1055d81f0432d305232fd71c19f6b to your computer and use it in GitHub Desktop.
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