(defun test3 (tbl) (let ((scor) (rule) (ret (list))) (dolist (results (wme-results *w*)) (dotimes (i 3) (setf rule (nth i results)) (setf scor (score rule t)) (setf ret (append ret (list rule scor))))) ret )) (defun test4 (set1 set2 b &optional (target1 "dataC/testFlw.txt") (target2 "dataC/testDef.txt")) (let ((ranges) (res) (rule) (scor) (name1) (name2) (headr) (x 0)) ;; Load train set (data set1) ;; Remember set name (setf name1 (table-name (thetable))) ;; Train for mins/maxes (train (thetable)) ;; Undiscretize (setf ranges (undisc2 b)) ;; Train to up sym-counts (train (thetable)) ;; Learn recommendations (learn (thetable) nil) ;; Load test set (data set2) ;; Remember set name (setf name2 (table-name (thetable))) ;; Train for discretizer (train (thetable)) ;; Undisc test data so it matched reccomendations (undisc b) ;; Get the results and dump to a couple files ;; One flawless the other defective, as tbl rows (setf res (test3 (thetable))) (setf headr "~12a ~12a ~5d ~5d ~5d ~5d ~5f ~5f ~5f ~5f ~3d ") (dotimes (j 3) (with-open-file (stream target1 :direction :output :if-exists :append :if-does-not-exist :create) (if (eql j 0) (format stream "Set 1 Set 2 A B C D Pd Pf Prec Acc Bin Rec~%")) (setf rule (nth x res)) ;;(format t "Flawless: ~a~%" rule) (incf x) (setf scor (nth x res)) (incf x) (format stream headr name1 name2 (scores-A scor) (scores-B scor) (scores-C scor) (scores-D scor) (* 100 (scores-pd scor)) (* 100 (scores-pf scor)) (* 100 (scores-prec scor)) (* 100 (scores-acc scor)) b) (printrule3 rule stream (first ranges) (nth 1 ranges)) (format stream "~%") (close stream)) ) (dotimes (j 3) (with-open-file (stream target2 :direction :output :if-exists :append :if-does-not-exist :create) (if (eql j 0) (format stream "Set 1 Set 2 A B C D Pd Pf Prec Acc Bin Rec~%")) (setf rule (nth x res)) ;;(format t "Defective: ~a~%" rule) (incf x) (setf scor (nth x res)) (incf x) (format stream headr name1 name2 (scores-A scor) (scores-B scor) (scores-C scor) (scores-D scor) (* 100 (scores-pd scor)) (* 100 (scores-pf scor)) (* 100 (scores-prec scor)) (* 100 (scores-acc scor)) b) (printrule3 rule stream (first ranges) (nth 1 ranges)) (format stream "~%") (close stream)) ) (with-open-file (stream target1 :direction :output :if-exists :append) (format stream "~%") (close stream)) (with-open-file (stream target2 :direction :output :if-exists :append) (format stream "~%") (close stream)) ))