(defn discretize-col [col] (let [sortcol (sort col) bincol (efb sortcol) mush (map #(vector %1 %2) sortcol bincol)] (loop [c col result (transient [])] (if (empty? c) (persistent! result) (recur (rest c) (conj! result (second (first (filter #(= (first c) (first %)) mush))))))))) (defn discretize [data] "a = binned version of data set b = each binned col matched to actual col" (let [issuper (to-vect (trans data)) unsuper (butlast issuper) a (bind-columns (trans (map discretize-col unsuper)) (matrix (last issuper))) b0 (map #(vector %1 %2) (butlast (to-vect (trans a))) unsuper) together (fn [one] (matrix (map #(vector %1 %2) (first one) (second one)))) b (map #(together %) b0)] [a b]))