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})
|
||||
(prn {:total-test-error
|
||||
(:total-error (error-function argmap (:testing-data argmap) best-individual))})
|
||||
(if (: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))]
|
||||
(when (:simplification? 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)))}))))
|
||||
;;
|
||||
(>= generation max-generations)
|
||||
|
@ -78,19 +78,14 @@
|
||||
(:step-limit argmap))
|
||||
:string))
|
||||
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]
|
||||
(if (= output :no-stack-item)
|
||||
10000
|
||||
(metrics/levenshtein-distance correct-output output)))
|
||||
correct-outputs
|
||||
parsed-outputs)]
|
||||
outputs)]
|
||||
(assoc individual
|
||||
:behaviors parsed-outputs
|
||||
:behaviors outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
@ -46,19 +46,14 @@
|
||||
(:step-limit argmap))
|
||||
:string))
|
||||
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]
|
||||
(if (= output :no-stack-item)
|
||||
10000
|
||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
||||
(metrics/levenshtein-distance correct-output output)))
|
||||
correct-outputs
|
||||
parsed-outputs)]
|
||||
outputs)]
|
||||
(assoc individual
|
||||
:behaviors parsed-outputs
|
||||
:behaviors outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
@ -47,19 +47,14 @@
|
||||
(:step-limit argmap))
|
||||
:string))
|
||||
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]
|
||||
(if (= output :no-stack-item)
|
||||
10000
|
||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
||||
(metrics/levenshtein-distance correct-output output)))
|
||||
correct-outputs
|
||||
parsed-outputs)]
|
||||
outputs)]
|
||||
(assoc individual
|
||||
:behaviors parsed-outputs
|
||||
:behaviors outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
@ -74,19 +74,14 @@
|
||||
(:step-limit argmap))
|
||||
:string))
|
||||
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]
|
||||
(if (= output :no-stack-item)
|
||||
10000
|
||||
(metrics/levenshtein-distance correct-output output)))
|
||||
correct-outputs
|
||||
parsed-outputs)]
|
||||
outputs)]
|
||||
(assoc individual
|
||||
:behaviors parsed-outputs
|
||||
:behaviors outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
@ -46,19 +46,14 @@
|
||||
(:step-limit argmap))
|
||||
:string))
|
||||
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]
|
||||
(if (= output :no-stack-item)
|
||||
10000
|
||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
||||
(metrics/levenshtein-distance correct-output output)))
|
||||
correct-outputs
|
||||
parsed-outputs)]
|
||||
outputs)]
|
||||
(assoc individual
|
||||
:behaviors parsed-outputs
|
||||
:behaviors outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
@ -59,19 +59,14 @@
|
||||
(:step-limit argmap))
|
||||
:string))
|
||||
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]
|
||||
(if (= output :no-stack-item)
|
||||
10000
|
||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
||||
(metrics/levenshtein-distance correct-output output)))
|
||||
correct-outputs
|
||||
parsed-outputs)]
|
||||
outputs)]
|
||||
(assoc individual
|
||||
:behaviors parsed-outputs
|
||||
:behaviors outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
@ -50,19 +50,14 @@
|
||||
(:step-limit argmap))
|
||||
:string))
|
||||
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]
|
||||
(if (= output :no-stack-item)
|
||||
10000
|
||||
(metrics/levenshtein-distance (str correct-output) (str output))))
|
||||
(metrics/levenshtein-distance correct-output output)))
|
||||
correct-outputs
|
||||
parsed-outputs)]
|
||||
outputs)]
|
||||
(assoc individual
|
||||
:behaviors parsed-outputs
|
||||
:behaviors outputs
|
||||
:errors errors
|
||||
:total-error #?(:clj (apply +' errors)
|
||||
:cljs (apply + errors)))))
|
||||
|
@ -121,9 +121,13 @@
|
||||
:name "_from_string"}
|
||||
(fn [stack state]
|
||||
(make-instruction state
|
||||
#(try ((if (= stack :integer) int float) (read-string %))
|
||||
#?(:clj (catch Exception e)
|
||||
:cljs (catch js/Error. e)))
|
||||
#(try (if (= stack :integer)
|
||||
#?(:clj (Integer/parseInt %)
|
||||
:cljs (js/parseInt %))
|
||||
#?(:clj (Float/parseFloat %)
|
||||
:cljs (js/parseFloat %)))
|
||||
#?(:clj (catch Exception e :ignore-instruction)
|
||||
:cljs (catch js/Error e :ignore-instruction)))
|
||||
[:string]
|
||||
stack)))
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
"deletes the values at given set of indices"
|
||||
[indices plushy]
|
||||
(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
|
||||
[k plushy]
|
||||
@ -21,13 +21,13 @@
|
||||
|
||||
(defn auto-simplify-plushy
|
||||
"naive auto-simplification"
|
||||
[argmap plushy steps error-function training-data k verbose?]
|
||||
(if verbose? (prn {:start-plushy-length (count plushy) :k k}))
|
||||
[plushy error-function {:keys [simplification-steps training-data simplification-k simplification-verbose?] :as argmap}]
|
||||
(when simplification-verbose? (prn {:start-plushy-length (count plushy) :k simplification-k}))
|
||||
(let [initial-errors (:errors (error-function argmap training-data {:plushy plushy}))]
|
||||
(loop [step 0 curr-plushy plushy]
|
||||
(if (< steps step)
|
||||
(do (if 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)
|
||||
(if (< simplification-steps step)
|
||||
(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 simplification-k) curr-plushy)
|
||||
new-plushy-errors (:errors (error-function argmap training-data {:plushy new-plushy}))
|
||||
new-equal? (= new-plushy-errors initial-errors)]
|
||||
(recur (inc step)
|
||||
|
Loading…
x
Reference in New Issue
Block a user