<commit_before><commit_msg>Added clojush.problems.regression.uball5d; lein release :minor<commit_after>;; uball5d.clj
;; an example problem for clojush, a Push/PushGP system written in Clojure
;; <NAME>, <EMAIL>, 2017

(ns clojush.problems.regression.uball5d
  (:use [clojush.pushgp.pushgp]
        [clojush.pushstate]
        [clojush.random]
        [clojush.interpreter]
        [clojure.math.numeric-tower]))

;;;;;;;;;;;;
;; Floating point symbolic regression of the Vladislavleva 2009 UBall5D problem.

;; Each training case will be in the form [[x1 x2 x3 x4 x5] y], where the xs are
;; inputs and y is the output.

(def uball5d-training-cases
  (for [xseq (repeatedly 1024
                         (fn [] (repeatedly 5 
                                            #(+ 0.05 (lrand 6.05)))))]
    [xseq
     (->> (map (fn [x] (#(* % %) (- x 3)))
               xseq)
          (reduce +)
          (+ 5)
          (/ 10.0))]))

(def argmap
  {:error-function (fn [program]
                     (doall
                       (for [[[x1 x2 x3 x4 x5] y] uball5d-training-cases]
                         (let [result (->> (run-push program 
                                                     (->> (make-push-state)
                                                          (push-item x1 :input)
                                                          (push-item x2 :input)
                                                          (push-item x3 :input)
                                                          (push-item x4 :input)
                                                          (push-item x5 :input)))
                                           (top-item :float))]
                           (if (number? result)
                             (Math/abs (- result y))
                             1000000)))))
   :atom-generators (conj '[float_div float_mult float_sub float_add
                            float_rot float_swap float_dup float_pop
                            in1 in2 in3 in4 in5]
                          lrand)
   :error-threshold 0.01
   :epigenetic-markers []
   :parent-selection :epsilon-lexicase
   :genetic-operator-probabilities {:alternation 0.5
                                    :uniform-mutation 0.5}})


{'fraction_non_alphanumeric': 0.10706352732119058, 'fraction_numerical': 0.028431808085295423, 'mean_word_length': 1.106641721234799, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3215177', 'n_tokens_mistral': 649, 'n_tokens_neox': 593, 'n_words': 153}