     (if (<= a-dist b-dist) a b)))
 
 
-(defn ch09-ml-toy
+(defn ch09-ml-with-one-third-test
   "See listings 9-3 through 9-6.
    Use r? true to use the same test selection that R generates.
 

                     float)]
    accuracy))

(defn ch09-ml-test [data test-sel]
  (let [test-data (-> (incanter.core/sel data :rows [test-sel] :cols [:proc :mem :state])
                      :rows
                      first)
        training-data (incanter.core/sel data :except-rows [test-sel])

        "Normal" tr-norm-proc-mean tr-norm-mem-mean
        (:proc test-data) (:mem test-data)))))

(defn ch09-ml-validate
  "Does leave-one-out cross-validation on memproc data.
   http://en.wikipedia.org/wiki/Cross-validation_(statistics)#Leave-one-out_cross-validation.

   ex: (ch09-ml-validate ch09-ml-null-model)
   ex: (ch09-ml-validate ch09-ml-book)"
  [ml-model-fn]
  (let [memproc (read-memproc-data)
        n (count (:rows memproc))
        test-size (dec n)
        tf-results (-> (for [test-sel (range n)]
                         (ml-model-fn memproc test-sel))
                       frequencies)]
    (float (/ (tf-results true) n))))

