;;;; macros (defmacro ! (&rest l) `(funcall (wme-! *w*) ',l)) (defmacro theu () `(wme-utility-function *w*)) (defmacro thefile () `(wme-file *w*)) (defmacro thetable () `(wme-table *w*)) (defmacro thecols (&optional tbl) `(table-cols (or ,tbl (wme-table *w*)))) (defmacro thename (&optional tbl) `(table-name (or ,tbl (wme-table *w*)))) (defmacro therows (&optional tbl) `(table-rows (or ,tbl (wme-table *w*)))) (defmacro theklasses (&optional tbl) `(table-klasses (or ,tbl (wme-table *w*)))) (defmacro theeval () `(wme-evalu *w*)) (defmacro theconfig () `(wme-configuration *w*)) (defmacro livesleft () `(wme-lives *w*)) ;;;; structs (defun arff (str &optional (tbl (thetable))) (setf (table-arffAttr tbl) (append (table-arffAttr tbl) (list str)))) (defstruct result target (a 0) (b 0) (c 0) (d 0) acc pf prec pd f details) (defstruct scores (a 0) (b 0) (c 0) (d 0) pd pf prec acc support lift fits) (defstruct table name rows klasses cols results arffAttr) (defstruct row cells class utility sortkey) ;;Utility stands for a number between 0.0 and 0.5 gives elements random order when sorted. (defstruct col name goalp) (defstruct klass name (n 0)) (defstruct (sym (:include col)) (counts (make-hash-table :test 'equal))) (defstruct (num (:include col)) (n 0) (sum 0) (sumsq 0) (min most-positive-fixnum) (max most-negative-fixnum) (mins (make-hash-table :test 'equal)) (maxs (make-hash-table :test 'equal)) ) (defstruct wme (goal #\!) (num #\$) (unknown '?) (file "../testData2.lisp") (utility-function #'zero) (! #'defrow) (ready #'sort-rows) (run #'noop) (report #'noop) table (configuration (make-config)) evalu (lives (config-lives (make-config))) ) (defstruct rig (preprocess #'noop) (train #'noop) (ready #'noop) (tester #'noop) (reporter #'noop) ) ;; Figure we would need these somewhere, stuff from BEGIN ;; Move if you find a better home for these (defstruct config (beam 10) (dull 0.1) (eval1 5) (eval2 1) (lives 5) (more 1.02) (overfitted 3) (pinch 0.000001) (samples 20) (seed 1) (skip 0.33) (verbose 1) ) (defstruct rule class ;yes or no, aka the answer klass ands ;classes anded together sorted ;boolean score ;number, stands for the the score that comes from b^2/(b+r) ) (defstruct ors for ;stands for a class, aka forcast, humidity, etc. values ;the values of that given class, aka sunny, rainy, overcast, etc ) (defstruct stack rules sorted ) ;;;; globals (defparameter *w* nil) (defun w0 () (setf *w* (make-wme))) ;;; utils (defun klass.majority (tbl) "return the symbol of the largest class" (maxof (table-klasses tbl) :key #'klass-n :result #'klass-name)) (defun klass.all (tbl &aux out) (mapcar #'klass-name (table-klasses tbl)))