(defn get-criteria [D] (let [br (my-best-rest4 D)] (loop [br1 br result []] (if (empty? br1) result (recur (rest br1) (conj result (rank-vals4 D (first (first br1)) (second (first br1))))))))) (defn select-instances1 [crit inst] (loop [c crit result inst] (if (or (= result nil) (<= (nrow result) (myutil? (nrow inst) 0.15))) result (recur (rest c) (matrix (filter #(= (nth % (last (first c))) (first (first c))) result)))))) (defn select-instances [crit inst] (loop [c crit prev inst result inst] (if (or (= result nil) (<= (nrow result) (myutil? (nrow inst) 0.15))) (if (= result nil) prev result) (recur (rest c) result (matrix (filter #(= (nth % (last (first c))) (first (first c))) (if (= (nrow result) 1) [result] result))))))) (defn cliff [D] (let [crits (get-criteria D) insts (group-by D (- (ncol D) 1))] (apply bind-rows (map #(select-instances %1 %2) crits insts))))