grade is now easier, more aligned with comparison. Doesn't use whole string, just output letter.

This commit is contained in:
Ryan Boldi 2022-08-14 09:34:31 -04:00
parent 75fd08e1dc
commit 6ffd3bea59

View File

@ -14,11 +14,20 @@
(def train-data (dc/read-data-formatted "grade" "train")) (def train-data (dc/read-data-formatted "grade" "train"))
(def test-data (dc/read-data-formatted "grade" "test")) (def test-data (dc/read-data-formatted "grade" "test"))
(def outputs (map (fn [i] (get i :output1)) train-data))
outputs
(defn map-vals-input (defn map-vals-input
"Returns all the input values of a map" "Returns all the input values of a map"
[i] [i]
(vals (select-keys i [:input1 :input2 :input3 :input4 :input5]))) (vals (select-keys i [:input1 :input2 :input3 :input4 :input5])))
(defn get-output
"returns the outputs of the grade function with JUST the letter grade"
[i]
(str (nth i 14)))
; Random integer between -100 and 100 ; Random integer between -100 and 100
(defn random-int [] (- (rand-int 201) 100)) (defn random-int [] (- (rand-int 201) 100))
@ -32,13 +41,13 @@
;;close ;;close
(list 'close) (list 'close)
;; ERCs (constants) ;; ERCs (constants)
(list "Student has a " " grade." "A" "B" "C" "D" "F" random-int)))) (list "A" "B" "C" "D" "F" random-int))))
(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 (map (fn [i] (map-vals-input i)) data) inputs (map (fn [i] (map-vals-input i)) data)
correct-outputs (map (fn [i] (get i :output1)) data) correct-outputs (map (fn [i] (get-output (get i :output1))) data)
outputs (map (fn [input] outputs (map (fn [input]
(state/peek-stack (state/peek-stack
(interpreter/interpret-program (interpreter/interpret-program