;;;; 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 (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) (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) (counts (make-hash-table :test 'equal)) ) (defstruct wme (goal #\!) (num #\$) (unknown #\?) (file "../data/discrete-lisp/weather.lisp") (utility-function #'zero) (! #'defrow) (ready #'sort-rows) (run #'noop) (report #'noop) table (configuration (make-config)) evalu (lives (config-lives (make-config))) results results2 ) (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 30) (dull 0.1) (eval1 7) (eval2 1) (lives 5) (more 1.02) (overfitted 4) (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 () (let (tmp tmp2) (if *w* (progn (if (wme-results *w*) (setf tmp (wme-results *w*))) (if (wme-results2 *w*) (setf tmp2 (wme-results2 *w*))))) (setf *w* (make-wme)) (setf (wme-results *w*) tmp ) (setf (wme-results2 *w*) tmp2))) ;;; 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)))