(ns code.pls.psc (:use (code.utils utils performance)) (:use (code.learners k_means)) (:use (incanter core stats))) (defn psc [k D distance _] (let [clusters (k-means-model k D distance) heterog (fn [onec] (loop [one onec results []] (if (empty? one) (remove #(= % 'none) results) (recur (rest one) (conj results (if (= (last (first one)) (last (first (get-nearest (first one) (rest one) distance)))) 'none (to-vect (first one)))))))) homog (fn [onec] [(to-vect (first (get-nearest (centroid onec) onec distance)))]) prototypes (loop [c clusters result []] (if (empty? c) (apply concat (remove #(empty? %) result)) (recur (rest c) (conj result (if (= (nrow (first c)) 1) [(first c)] (if (same? (to-vect (last (trans (first c))))) (homog (first c)) (heterog (first c))))))))] (extract-unique (matrix prototypes))))