 (ns k-means.core
-  (:gen-class))
+  (:gen-class)
+  (:require [taoensso.timbre.profiling :as profiling :refer (p profile)]))
+
 
 (defn choose-initial-centroids
   "Randomly choose k centroids from vectors"

(defn k-means
  "Perform the actual k-means"
  ([l k max-iterations]
    (k-means l k (choose-initial-centroids l k) (make-vector k) max-iterations))
  ([l k c g max-iterations]
    (let [t c g (cluster g l c) c (mean-centroids g)]
      (println c)
      ; (println (still-moving? t c))
      (cond
        (> 0 max-iterations) g

    (cond
      (empty? g) l
      :else
        (recur (rest g) (conj l (p :mean-2dvec (mean-2dvec (first g))))))))

(defn distance
  "Implements euclidian distance between two vectors"
  ([c1 c2]
    (->> (map - c1 c2) (map #(* % %)) (reduce +))))

(defn min-index
  [c]
  (.indexOf c (apply min c)))
