Merge branch 'master' of https://www.github.com/lspector/propeller into downsample
This commit is contained in:
commit
4a03a19190
@ -65,8 +65,8 @@
|
|||||||
(do (prn {:success-generation generation})
|
(do (prn {:success-generation generation})
|
||||||
(prn {:total-test-error
|
(prn {:total-test-error
|
||||||
(:total-error (error-function argmap (:testing-data argmap) best-individual))})
|
(:total-error (error-function argmap (:testing-data argmap) best-individual))})
|
||||||
(if (:simplification? argmap)
|
(when (:simplification? argmap)
|
||||||
(let [simplified-plushy (simplification/auto-simplify-plushy argmap (:plushy best-individual) (:simplification-steps argmap) error-function (:testing-data argmap) (:simplification-k argmap) (:simplification-verbose? argmap))]
|
(let [simplified-plushy (simplification/auto-simplify-plushy (:plushy best-individual) error-function argmap)]
|
||||||
(prn {:total-test-error-simplified (:total-error (error-function argmap (:testing-data argmap) (hash-map :plushy simplified-plushy)))}))))
|
(prn {:total-test-error-simplified (:total-error (error-function argmap (:testing-data argmap) (hash-map :plushy simplified-plushy)))}))))
|
||||||
;;
|
;;
|
||||||
(>= generation max-generations)
|
(>= generation max-generations)
|
||||||
|
@ -78,19 +78,14 @@
|
|||||||
(:step-limit argmap))
|
(:step-limit argmap))
|
||||||
:string))
|
:string))
|
||||||
inputs)
|
inputs)
|
||||||
parsed-outputs (map (fn [output]
|
|
||||||
(try (read-string output)
|
|
||||||
#?(:clj (catch Exception e 1000.0)
|
|
||||||
:cljs (catch js/Error. e 1000.0))))
|
|
||||||
outputs)
|
|
||||||
errors (map (fn [correct-output output]
|
errors (map (fn [correct-output output]
|
||||||
(if (= output :no-stack-item)
|
(if (= output :no-stack-item)
|
||||||
10000
|
10000
|
||||||
(metrics/levenshtein-distance correct-output output)))
|
(metrics/levenshtein-distance correct-output output)))
|
||||||
correct-outputs
|
correct-outputs
|
||||||
parsed-outputs)]
|
outputs)]
|
||||||
(assoc individual
|
(assoc individual
|
||||||
:behaviors parsed-outputs
|
:behaviors outputs
|
||||||
:errors errors
|
:errors errors
|
||||||
:total-error #?(:clj (apply +' errors)
|
:total-error #?(:clj (apply +' errors)
|
||||||
:cljs (apply + errors)))))
|
:cljs (apply + errors)))))
|
||||||
|
@ -46,19 +46,14 @@
|
|||||||
(:step-limit argmap))
|
(:step-limit argmap))
|
||||||
:string))
|
:string))
|
||||||
inputs)
|
inputs)
|
||||||
parsed-outputs (map (fn [output]
|
|
||||||
(try (read-string output)
|
|
||||||
#?(:clj (catch Exception e 1000.0)
|
|
||||||
:cljs (catch js/Error. e 1000.0))))
|
|
||||||
outputs)
|
|
||||||
errors (map (fn [correct-output output]
|
errors (map (fn [correct-output output]
|
||||||
(if (= output :no-stack-item)
|
(if (= output :no-stack-item)
|
||||||
10000
|
10000
|
||||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
(metrics/levenshtein-distance correct-output output)))
|
||||||
correct-outputs
|
correct-outputs
|
||||||
parsed-outputs)]
|
outputs)]
|
||||||
(assoc individual
|
(assoc individual
|
||||||
:behaviors parsed-outputs
|
:behaviors outputs
|
||||||
:errors errors
|
:errors errors
|
||||||
:total-error #?(:clj (apply +' errors)
|
:total-error #?(:clj (apply +' errors)
|
||||||
:cljs (apply + errors)))))
|
:cljs (apply + errors)))))
|
||||||
|
@ -47,19 +47,14 @@
|
|||||||
(:step-limit argmap))
|
(:step-limit argmap))
|
||||||
:string))
|
:string))
|
||||||
inputs)
|
inputs)
|
||||||
parsed-outputs (map (fn [output]
|
|
||||||
(try (read-string output)
|
|
||||||
#?(:clj (catch Exception e 1000.0)
|
|
||||||
:cljs (catch js/Error. e 1000.0))))
|
|
||||||
outputs)
|
|
||||||
errors (map (fn [correct-output output]
|
errors (map (fn [correct-output output]
|
||||||
(if (= output :no-stack-item)
|
(if (= output :no-stack-item)
|
||||||
10000
|
10000
|
||||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
(metrics/levenshtein-distance correct-output output)))
|
||||||
correct-outputs
|
correct-outputs
|
||||||
parsed-outputs)]
|
outputs)]
|
||||||
(assoc individual
|
(assoc individual
|
||||||
:behaviors parsed-outputs
|
:behaviors outputs
|
||||||
:errors errors
|
:errors errors
|
||||||
:total-error #?(:clj (apply +' errors)
|
:total-error #?(:clj (apply +' errors)
|
||||||
:cljs (apply + errors)))))
|
:cljs (apply + errors)))))
|
||||||
|
@ -74,19 +74,14 @@
|
|||||||
(:step-limit argmap))
|
(:step-limit argmap))
|
||||||
:string))
|
:string))
|
||||||
inputs)
|
inputs)
|
||||||
parsed-outputs (map (fn [output]
|
|
||||||
(try (read-string output)
|
|
||||||
#?(:clj (catch Exception e 1000.0)
|
|
||||||
:cljs (catch js/Error. e 1000.0))))
|
|
||||||
outputs)
|
|
||||||
errors (map (fn [correct-output output]
|
errors (map (fn [correct-output output]
|
||||||
(if (= output :no-stack-item)
|
(if (= output :no-stack-item)
|
||||||
10000
|
10000
|
||||||
(metrics/levenshtein-distance correct-output output)))
|
(metrics/levenshtein-distance correct-output output)))
|
||||||
correct-outputs
|
correct-outputs
|
||||||
parsed-outputs)]
|
outputs)]
|
||||||
(assoc individual
|
(assoc individual
|
||||||
:behaviors parsed-outputs
|
:behaviors outputs
|
||||||
:errors errors
|
:errors errors
|
||||||
:total-error #?(:clj (apply +' errors)
|
:total-error #?(:clj (apply +' errors)
|
||||||
:cljs (apply + errors)))))
|
:cljs (apply + errors)))))
|
||||||
|
@ -46,19 +46,14 @@
|
|||||||
(:step-limit argmap))
|
(:step-limit argmap))
|
||||||
:string))
|
:string))
|
||||||
inputs)
|
inputs)
|
||||||
parsed-outputs (map (fn [output]
|
|
||||||
(try (read-string output)
|
|
||||||
#?(:clj (catch Exception e 1000.0)
|
|
||||||
:cljs (catch js/Error. e 1000.0))))
|
|
||||||
outputs)
|
|
||||||
errors (map (fn [correct-output output]
|
errors (map (fn [correct-output output]
|
||||||
(if (= output :no-stack-item)
|
(if (= output :no-stack-item)
|
||||||
10000
|
10000
|
||||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
(metrics/levenshtein-distance correct-output output)))
|
||||||
correct-outputs
|
correct-outputs
|
||||||
parsed-outputs)]
|
outputs)]
|
||||||
(assoc individual
|
(assoc individual
|
||||||
:behaviors parsed-outputs
|
:behaviors outputs
|
||||||
:errors errors
|
:errors errors
|
||||||
:total-error #?(:clj (apply +' errors)
|
:total-error #?(:clj (apply +' errors)
|
||||||
:cljs (apply + errors)))))
|
:cljs (apply + errors)))))
|
||||||
|
@ -59,19 +59,14 @@
|
|||||||
(:step-limit argmap))
|
(:step-limit argmap))
|
||||||
:string))
|
:string))
|
||||||
inputs)
|
inputs)
|
||||||
parsed-outputs (map (fn [output]
|
|
||||||
(try (read-string output)
|
|
||||||
#?(:clj (catch Exception e 1000.0)
|
|
||||||
:cljs (catch js/Error. e 1000.0))))
|
|
||||||
outputs)
|
|
||||||
errors (map (fn [correct-output output]
|
errors (map (fn [correct-output output]
|
||||||
(if (= output :no-stack-item)
|
(if (= output :no-stack-item)
|
||||||
10000
|
10000
|
||||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
(metrics/levenshtein-distance correct-output output)))
|
||||||
correct-outputs
|
correct-outputs
|
||||||
parsed-outputs)]
|
outputs)]
|
||||||
(assoc individual
|
(assoc individual
|
||||||
:behaviors parsed-outputs
|
:behaviors outputs
|
||||||
:errors errors
|
:errors errors
|
||||||
:total-error #?(:clj (apply +' errors)
|
:total-error #?(:clj (apply +' errors)
|
||||||
:cljs (apply + errors)))))
|
:cljs (apply + errors)))))
|
||||||
|
@ -50,19 +50,14 @@
|
|||||||
(:step-limit argmap))
|
(:step-limit argmap))
|
||||||
:string))
|
:string))
|
||||||
inputs)
|
inputs)
|
||||||
parsed-outputs (map (fn [output]
|
|
||||||
(try (read-string output)
|
|
||||||
#?(:clj (catch Exception e 1000.0)
|
|
||||||
:cljs (catch js/Error. e 1000.0))))
|
|
||||||
outputs)
|
|
||||||
errors (map (fn [correct-output output]
|
errors (map (fn [correct-output output]
|
||||||
(if (= output :no-stack-item)
|
(if (= output :no-stack-item)
|
||||||
10000
|
10000
|
||||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
(metrics/levenshtein-distance correct-output output)))
|
||||||
correct-outputs
|
correct-outputs
|
||||||
parsed-outputs)]
|
outputs)]
|
||||||
(assoc individual
|
(assoc individual
|
||||||
:behaviors parsed-outputs
|
:behaviors outputs
|
||||||
:errors errors
|
:errors errors
|
||||||
:total-error #?(:clj (apply +' errors)
|
:total-error #?(:clj (apply +' errors)
|
||||||
:cljs (apply + errors)))))
|
:cljs (apply + errors)))))
|
||||||
|
@ -121,9 +121,13 @@
|
|||||||
:name "_from_string"}
|
:name "_from_string"}
|
||||||
(fn [stack state]
|
(fn [stack state]
|
||||||
(make-instruction state
|
(make-instruction state
|
||||||
#(try ((if (= stack :integer) int float) (read-string %))
|
#(try (if (= stack :integer)
|
||||||
#?(:clj (catch Exception e)
|
#?(:clj (Integer/parseInt %)
|
||||||
:cljs (catch js/Error. e)))
|
:cljs (js/parseInt %))
|
||||||
|
#?(:clj (Float/parseFloat %)
|
||||||
|
:cljs (js/parseFloat %)))
|
||||||
|
#?(:clj (catch Exception e :ignore-instruction)
|
||||||
|
:cljs (catch js/Error e :ignore-instruction)))
|
||||||
[:string]
|
[:string]
|
||||||
stack)))
|
stack)))
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
"deletes the values at given set of indices"
|
"deletes the values at given set of indices"
|
||||||
[indices plushy]
|
[indices plushy]
|
||||||
(let [sorted-indices (sort > indices)]
|
(let [sorted-indices (sort > indices)]
|
||||||
(keep-indexed #(if (not (some #{%1} sorted-indices)) %2) plushy)))
|
(keep-indexed #(when (not (some #{%1} sorted-indices)) %2) plushy)))
|
||||||
|
|
||||||
(defn delete-k-random
|
(defn delete-k-random
|
||||||
[k plushy]
|
[k plushy]
|
||||||
@ -21,13 +21,13 @@
|
|||||||
|
|
||||||
(defn auto-simplify-plushy
|
(defn auto-simplify-plushy
|
||||||
"naive auto-simplification"
|
"naive auto-simplification"
|
||||||
[argmap plushy steps error-function training-data k verbose?]
|
[plushy error-function {:keys [simplification-steps training-data simplification-k simplification-verbose?] :as argmap}]
|
||||||
(if verbose? (prn {:start-plushy-length (count plushy) :k k}))
|
(when simplification-verbose? (prn {:start-plushy-length (count plushy) :k simplification-k}))
|
||||||
(let [initial-errors (:errors (error-function argmap training-data {:plushy plushy}))]
|
(let [initial-errors (:errors (error-function argmap training-data {:plushy plushy}))]
|
||||||
(loop [step 0 curr-plushy plushy]
|
(loop [step 0 curr-plushy plushy]
|
||||||
(if (< steps step)
|
(if (< simplification-steps step)
|
||||||
(do (if verbose? (prn {:final-plushy-length (count curr-plushy) :final-plushy curr-plushy})) curr-plushy)
|
(do (when simplification-verbose? (prn {:final-plushy-length (count curr-plushy) :final-plushy curr-plushy})) curr-plushy)
|
||||||
(let [new-plushy (delete-k-random (rand-int k) curr-plushy)
|
(let [new-plushy (delete-k-random (rand-int simplification-k) curr-plushy)
|
||||||
new-plushy-errors (:errors (error-function argmap training-data {:plushy new-plushy}))
|
new-plushy-errors (:errors (error-function argmap training-data {:plushy new-plushy}))
|
||||||
new-equal? (= new-plushy-errors initial-errors)]
|
new-equal? (= new-plushy-errors initial-errors)]
|
||||||
(recur (inc step)
|
(recur (inc step)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user