Merge pull request #44 from ryanboldi/fixed-data-representations
Made all training data representations consistent with PSB2
This commit is contained in:
commit
e47db0f5f6
@ -14,10 +14,8 @@
|
|||||||
(def train-and-test-data
|
(def train-and-test-data
|
||||||
(let [train-inputs (range -10 11)
|
(let [train-inputs (range -10 11)
|
||||||
test-inputs (concat (range -20 -10) (range 11 21))]
|
test-inputs (concat (range -20 -10) (range 11 21))]
|
||||||
{:train {:inputs train-inputs
|
{:train (map (fn [x] {:input1 (vector x) :output1 (vector (target-function x))}) train-inputs)
|
||||||
:outputs (map target-function train-inputs)}
|
:test (map (fn [x] {:input1 (vector x) :output1 (vector (target-function x))}) test-inputs)}))
|
||||||
:test {:inputs test-inputs
|
|
||||||
:outputs (map target-function test-inputs)}}))
|
|
||||||
|
|
||||||
(def instructions
|
(def instructions
|
||||||
(list :in1
|
(list :in1
|
||||||
@ -39,8 +37,8 @@
|
|||||||
final top item on the INTEGER stack."
|
final top item on the INTEGER stack."
|
||||||
([argmap data individual]
|
([argmap data individual]
|
||||||
(let [program (genome/plushy->push (:plushy individual) argmap)
|
(let [program (genome/plushy->push (:plushy individual) argmap)
|
||||||
inputs (:inputs data)
|
inputs (map (fn [x] (first (:input1 x))) data)
|
||||||
correct-outputs (:outputs data)
|
correct-outputs (map (fn [x] (first (:output1 x))) data)
|
||||||
outputs (map (fn [input]
|
outputs (map (fn [input]
|
||||||
(state/peek-stack
|
(state/peek-stack
|
||||||
(interpreter/interpret-program
|
(interpreter/interpret-program
|
||||||
|
@ -44,11 +44,11 @@
|
|||||||
|
|
||||||
(def train-and-test-data
|
(def train-and-test-data
|
||||||
(let [train-inputs ["GCG" "GACAG" "AGAAG" "CCCA" "GATTACA" "TAGG" "GACT"]
|
(let [train-inputs ["GCG" "GACAG" "AGAAG" "CCCA" "GATTACA" "TAGG" "GACT"]
|
||||||
test-inputs ["GCGT" "GACTTAG" "AGTAAG" "TCCTCA" "GAACA" "AGG" "GAC"]]
|
test-inputs ["GCGT" "GACTTAG" "AGTAAG" "TCCTCA" "GAACA" "AGG" "GAC"]
|
||||||
{:train {:inputs train-inputs
|
train-outputs [false false false false true true true]
|
||||||
:outputs [false false false false true true true]}
|
test-outputs [true true true true false false false]]
|
||||||
:test {:inputs test-inputs
|
{:train (map (fn [in out] {:input1 (vector in) :output1 (vector out)}) train-inputs train-outputs)
|
||||||
:outputs [true true true true false false false]}}))
|
:test (map (fn [in out] {:input1 (vector in) :output1 (vector out)}) test-inputs test-outputs)}))
|
||||||
|
|
||||||
(defn error-function
|
(defn error-function
|
||||||
"Finds the behaviors and errors of an individual: Error is 0 if the value and
|
"Finds the behaviors and errors of an individual: Error is 0 if the value and
|
||||||
@ -57,8 +57,8 @@
|
|||||||
the BOOLEAN stack."
|
the BOOLEAN stack."
|
||||||
[argmap data individual]
|
[argmap data individual]
|
||||||
(let [program (genome/plushy->push (:plushy individual) argmap)
|
(let [program (genome/plushy->push (:plushy individual) argmap)
|
||||||
inputs (:inputs data)
|
inputs (map (fn [x] (first (:input1 x))) data)
|
||||||
correct-outputs (:outputs data)
|
correct-outputs (map (fn [x] (first (:output1 x))) data)
|
||||||
outputs (map (fn [input]
|
outputs (map (fn [input]
|
||||||
(state/peek-stack
|
(state/peek-stack
|
||||||
(interpreter/interpret-program
|
(interpreter/interpret-program
|
||||||
|
@ -19,10 +19,8 @@
|
|||||||
input-indices)))))
|
input-indices)))))
|
||||||
train-inputs (repeatedly num-train rand-vars)
|
train-inputs (repeatedly num-train rand-vars)
|
||||||
test-inputs (repeatedly num-test rand-vars)]
|
test-inputs (repeatedly num-test rand-vars)]
|
||||||
{:train {:inputs train-inputs
|
{:train (map (fn [x] {:input1 x :output1 (vector (even-parity? x))}) train-inputs)
|
||||||
:outputs (map even-parity? train-inputs)}
|
:test (map (fn [x] {:input1 x :output1 (vector (even-parity? x))}) test-inputs)}))
|
||||||
:test {:inputs test-inputs
|
|
||||||
:outputs (map even-parity? test-inputs)}}))
|
|
||||||
|
|
||||||
(def instructions
|
(def instructions
|
||||||
(vec (concat (for [i (range num-vars)] (keyword (str "in" i)))
|
(vec (concat (for [i (range num-vars)] (keyword (str "in" i)))
|
||||||
@ -38,8 +36,8 @@
|
|||||||
(defn error-function
|
(defn error-function
|
||||||
[argmap data individual]
|
[argmap data individual]
|
||||||
(let [program (genome/plushy->push (:plushy individual) argmap)
|
(let [program (genome/plushy->push (:plushy individual) argmap)
|
||||||
inputs (:inputs data)
|
inputs (map (fn [x] (:input1 x)) data)
|
||||||
correct-outputs (:outputs data)
|
correct-outputs (map (fn [x] (first (:output1 x))) data)
|
||||||
outputs (map (fn [input]
|
outputs (map (fn [input]
|
||||||
(state/peek-stack
|
(state/peek-stack
|
||||||
(interpreter/interpret-program
|
(interpreter/interpret-program
|
||||||
|
Loading…
x
Reference in New Issue
Block a user