Improve efficiency of motley-batch-lexicase-selection
This commit is contained in:
parent
06e9f9445d
commit
1facb741e6
@ -31,26 +31,24 @@
|
|||||||
|
|
||||||
(defn motley-batch-lexicase-selection
|
(defn motley-batch-lexicase-selection
|
||||||
"Selects an individual from the population using motley batch lexicase selection.
|
"Selects an individual from the population using motley batch lexicase selection.
|
||||||
Cases are combined in random collections of max size (:max-batch-size argmap),
|
Cases are combined in random collections of max size (:max-batch-size argmap)."
|
||||||
and then the population is passed to lexicase-selection."
|
|
||||||
[pop argmap]
|
[pop argmap]
|
||||||
(let [cases (range (count (:errors (first pop))))
|
(loop [survivors (map rand-nth (vals (group-by :errors pop)))
|
||||||
batches (loop [remaining (shuffle cases)
|
cases (shuffle (range (count (:errors (first pop)))))]
|
||||||
result ()]
|
(if (or (empty? cases)
|
||||||
(if (empty? remaining)
|
(empty? (rest survivors)))
|
||||||
result
|
(rand-nth survivors)
|
||||||
(let [n (inc (rand-int (:max-batch-size argmap)))]
|
(let [batch-size (inc (rand-int (:max-batch-size argmap)))
|
||||||
(recur (drop n remaining)
|
batch (take batch-size cases)
|
||||||
(conj result (take n remaining))))))]
|
ind-err-pairs (map (fn [ind]
|
||||||
(lexicase-selection (mapv (fn [ind]
|
[ind
|
||||||
(assoc ind
|
|
||||||
:errors
|
|
||||||
(mapv (fn [batch]
|
|
||||||
(reduce + (map #(nth (:errors ind) %)
|
(reduce + (map #(nth (:errors ind) %)
|
||||||
batch)))
|
batch))])
|
||||||
batches)))
|
survivors)
|
||||||
pop)
|
min-err (apply min (map second ind-err-pairs))]
|
||||||
argmap)))
|
(recur (map first (filter #(= (second %) min-err)
|
||||||
|
ind-err-pairs))
|
||||||
|
(drop batch-size cases))))))
|
||||||
|
|
||||||
(defn epsilon-list
|
(defn epsilon-list
|
||||||
"List of epsilons for each training case based on median absolute deviation of errors."
|
"List of epsilons for each training case based on median absolute deviation of errors."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user