(defun runTime (folder) (with-open-file (file (format nil "makecharts/data/~A/WrapperResults.dat" folder)) (let ((line (read file)) (egs (list))) (while (> (list-length line) 0) (let ((names (pop line)) (abcds (pop line)) (datasets (list))) (if (null (assoc (nth 6 names) egs)) (push (cons (nth 6 names) nil) egs)) (push (nth 9 names) (cdr (assoc (nth 6 names) egs))))) (format t "~%Runtime for ~A" folder) (let ((lst (list))) (mapcar #'(lambda (x) (setf (cdr x) (stable-sort (cdr x) #'<)) (let ((minsize (reduce #'min (cdr x))) (maxsize (reduce #'max (cdr x))) (mediansize (median (cdr x))) (meansize (mean (cdr x)))) (push (list (car x) minsize maxsize mediansize meansize) lst))) egs) (setf lst (stable-sort lst #'< :key #'fourth)) (push (list "Rule Generator" "Min" "Max" "Median" "Mean") lst) (align lst))))) (defun treeSizeLst (folder) (with-open-file (file (format nil "makecharts/data/~A/WrapperResults.dat" folder)) (let ((line (read file)) (egs (list))) (while (> (list-length line) 0) (let ((names (pop line)) (abcds (pop line)) (datasets (list))) (if (null (assoc (nth 6 names) egs)) (push (cons (nth 6 names) nil) egs)) (push (nth 12 names) (cdr (assoc (nth 6 names) egs))))) (format t "~%Tree Size for ~A" folder) (let ((lst (list))) (mapcar #'(lambda (x) (setf (cdr x) (stable-sort (cdr x) #'<)) (let ((minsize (reduce #'min (cdr x))) (maxsize (reduce #'max (cdr x))) (mediansize (median (cdr x))) (meansize (mean (cdr x)))) (push (list (car x) (round minsize) (round maxsize) (round mediansize) (round meansize)) lst))) egs) (setf lst (stable-sort lst #'< :key #'fourth)) (push (list "Rule Generator" "Min" "Max" "Median" "Mean") lst) (align lst))))) (defun quartile (folder statfunc num) (with-open-file (file (format nil "makecharts/data/~A/WrapperResults.dat" folder)) (let ((line (read file)) (egs (list))) (push (cons 'NB nil) egs) (while (> (list-length line) 0) (let ((names (pop line)) (abcds (pop line)) (datasets (list))) (mapcar #'(lambda (x) (if (or (equal (abcd-for x) 'TRUE) (equal (abcd-for x) 'YES)) (push (fround (funcall statfunc x)) (cdr (assoc 'NB egs))))) (naivebayes 5 (discretize (funcall (nth 3 names)) 10) :verbose nil)) (mapcar #'(lambda (y) (mapcar #'(lambda (x) (if (or (equal (aref x 2) 'TRUE) (equal (aref x 2) 'YES)) (progn (if (null (assoc (nth 6 names) egs)) (push (cons (nth 6 names) nil) egs)) (push (aref x num) (cdr (assoc (nth 6 names) egs)))))) (rest y))) abcds) )) ;(push (cons 'NB egs)) ;(mapcar #'(lambda (x) ; (push (pd (naivebayes 10 (discretize (funcall x) 10))) (cdr (assoc 'NB egs)))) ; datasets) (setf egs (stable-sort egs #'< :key #'(lambda (x) (median (cdr x))))) (mapcar #'(lambda (x) ;(print (stable-sort (cdr x) #'<)) (setf (cdr x) (stable-sort (cdr x) #'<)) (let ((p0 (reduce #'min (cdr x))) (p100 (reduce #'max (cdr x))) (p50 (median (cdr x))) (p25 (nth (round (/ (length (cdr x)) 4)) x)) (p75 (nth (round (* (/ (length (cdr x)) 4) 3)) x))) (setf (cdr (assoc (car x) egs)) (list p0 p25 p50 p75 p100)) (format t "[~A~A~A|~A~A~A] ~A[~A,~A,~A,~A,~A]~%" (nchars (round (* 40 p0)) " ") (nchars (- (round (* 40 p25)) (round (* 40 p0))) ".") (nchars (- (round (* 40 p50)) (round (* 40 p25))) "-") (nchars (- (round (* 40 p75)) (round (* 40 p50))) "-") (nchars (- (round (* 40 p100)) (round (* 40 p75))) ".") (nchars (- 40 (round (* 40 p100))) " ") (car x) p0 p25 p50 p75 p100))) ;(print (round (/ (length (cdr x)) 4))) ;(print (format nil "~A = (~A, ~A, ~A, ~A, ~A)" (car x) p0 p25 p50 p75 p100)))) egs) t))) (defun parseWrapperResults (&optional (filepath "WrapperResults.dat")) (with-open-file (file (format nil "makecharts/data/~A" filepath) :direction :input) (let ((line (read file)) (egs (list))) (while (> (list-length line) 0) (let ((names (pop line)) (abcds (pop line)) (avgabcd (make-abcd))) (mapcar #'(lambda (y) (mapcar #'(lambda (x) (if (or (equal (aref x 2) 'TRUE) (equal (aref x 2) 'YES)) (progn (incf (abcd-a avgabcd) (aref x 4)) (incf (abcd-b avgabcd) (aref x 6)) (incf (abcd-c avgabcd) (aref x 8)) (incf (abcd-d avgabcd) (aref x 10))))) (rest y))) ;(decf (abcd-a avgabcd) (+ (aref (first (rest y)) 4) (aref (last (rest y)) 4))) ;(decf (abcd-b avgabcd) (+ (aref (first (rest y)) 6) (aref (last (rest y)) 6))) ;(decf (abcd-c avgabcd) (+ (aref (first (rest y)) 8) (aref (last (rest y)) 8))) ;(decf (abcd-d avgabcd) (+ (aref (first (rest y)) 10) (aref (last (rest y)) 10)))) abcds) (push (list (table-name (funcall (nth 3 names))) (nth 6 names) (pd avgabcd)) egs))) ;(if (not (equal (table-name (funcall (nth 3 names))) "MUSHROOM")) ;(push (list (counted-n (table-columns (funcall (nth 3 names)))) (nth 6 names) (nth 9 names)) egs)))) ;(push (list (counted-n (table-all (funcall (nth 3 names)))) (nth 6 names) (nth 9 names)) egs)))) ;(push (list (hash-table-count (xindex-uniques (cross-index (discretize (funcall (nth 3 names)) 10)))) (nth 6 names) (nth 9 names)) egs)))) ;(print egs) ;(with-open-file (file "makecharts/data/Runtime.dat" :direction :output :if-does-not-exist :create :if-exists :rename) ; (while (> (length egs) 0) ; (let ((l1 (pop egs)) ; (l2 (pop egs)) ; (l3 (pop egs)) ; (l4 (pop egs)) ; (l5 (pop egs)) ; (l6 (pop egs))) ; (format file "~A ~A ~A ~A ~A ~A ~A~%" (first l1) (third l1) (third l2) (third l3) (third l4) (third l5) (third l6))))) ;;Egs holds a list of lists. ;;The inner lists holds three elements (DatasetName Treatment Statistic) ;;The statistic is something like pd, pf, etc... (let ((datahash (make-hash-table))) (mapcar #'(lambda (x) (push (cons (nth 1 x) (fround (nth 2 x))) (gethash (nth 0 x) datahash (list)))) egs) ;(showh datahash) (maphash #'(lambda (k v) (let ((stats (make-abcd))) (mapcar #'(lambda (x) (if (or (equal (abcd-for x) 'YES) (equal (abcd-for x) 'TRUE)) (progn (incf (abcd-a stats) (abcd-a x)) (incf (abcd-b stats) (abcd-b x)) (incf (abcd-c stats) (abcd-c x)) (incf (abcd-d stats) (abcd-d x))))) (naiveBayes 5 (discretize (funcall k) 10) :verbose nil)) (push (cons 'ICCLE-NB (fround (pd stats))) (gethash k datahash)))) ;)) datahash) (showh datahash) (with-open-file (out "/home/bryanl/public_html/Results.csv" :direction :output :if-does-not-exist :create :if-exists :supersede) ;(format out "DataSet, INB, NB, ANB, WR, AWR, R, AR~%") (maphash #'(lambda (k v) (format out "~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A, ~A~%" k (cdr (assoc 'ICCLE-NB v)) (cdr (assoc 'NB-local-xp-prob v)) (cdr (assoc 'MINUS-AVOID-NB-local-xp-prob v)) (cdr (assoc 'WEIGHTED-RANDOM-local-xp-prob v)) (cdr (assoc 'AVOID-WEIGHTED-RANDOM-local-xp-prob v)) (cdr (assoc 'RANDOM-local-xp-prob v)) (cdr (assoc 'MINUS-AVOID-RANDOM-local-xp-prob v)) ;(cdr (assoc 'ICCLE-NB-local-xp-freq v)) (cdr (assoc 'NB-local-xp-freq v)) (cdr (assoc 'MINUS-AVOID-NB-local-xp-freq v)) (cdr (assoc 'WEIGHTED-RANDOM-local-xp-freq v)) (cdr (assoc 'AVOID-WEIGHTED-RANDOM-local-xp-freq v)) (cdr (assoc 'RANDOM-local-xp-freq v)) (cdr (assoc 'MINUS-AVOID-RANDOM-local-xp-freq v)) ;(cdr (assoc 'ICCLE-NB-local-1p-prob v)) (cdr (assoc 'NB-local-1p-prob v)) (cdr (assoc 'MINUS-AVOID-NB-local-1p-prob v)) (cdr (assoc 'WEIGHTED-RANDOM-local-1p-prob v)) (cdr (assoc 'AVOID-WEIGHTED-RANDOM-local-1p-prob v)) (cdr (assoc 'RANDOM-local-1p-prob v)) (cdr (assoc 'MINUS-AVOID-RANDOM-local-1p-prob v)) ;(cdr (assoc 'ICCLE-NB-local-1p-freq v)) (cdr (assoc 'NB-local-1p-freq v)) (cdr (assoc 'MINUS-AVOID-NB-local-1p-freq v)) (cdr (assoc 'WEIGHTED-RANDOM-local-1p-freq v)) (cdr (assoc 'AVOID-WEIGHTED-RANDOM-local-1p-freq v)) (cdr (assoc 'RANDOM-local-1p-freq v)) (cdr (assoc 'MINUS-AVOID-RANDOM-local-1p-freq v)) ;(cdr (assoc 'ICCLE-NB-global-xp-prob v)) (cdr (assoc 'NB-global-xp-prob v)) (cdr (assoc 'MINUS-AVOID-NB-global-xp-prob v)) (cdr (assoc 'WEIGHTED-RANDOM-global-xp-prob v)) (cdr (assoc 'AVOID-WEIGHTED-RANDOM-global-xp-prob v)) (cdr (assoc 'RANDOM-global-xp-prob v)) (cdr (assoc 'MINUS-AVOID-RANDOM-global-xp-prob v)) ;(cdr (assoc 'ICCLE-NB-global-xp-freq v)) (cdr (assoc 'NB-global-xp-freq v)) (cdr (assoc 'MINUS-AVOID-NB-global-xp-freq v)) (cdr (assoc 'WEIGHTED-RANDOM-global-xp-freq v)) (cdr (assoc 'AVOID-WEIGHTED-RANDOM-global-xp-freq v)) (cdr (assoc 'RANDOM-global-xp-freq v)) (cdr (assoc 'MINUS-AVOID-RANDOM-global-xp-freq v)) ;(cdr (assoc 'ICCLE-NB-global-1p-prob v)) (cdr (assoc 'NB-global-1p-prob v)) (cdr (assoc 'MINUS-AVOID-NB-global-1p-prob v)) (cdr (assoc 'WEIGHTED-RANDOM-global-1p-prob v)) (cdr (assoc 'AVOID-WEIGHTED-RANDOM-global-1p-prob v)) (cdr (assoc 'RANDOM-global-1p-prob v)) (cdr (assoc 'MINUS-AVOID-RANDOM-global-1p-prob v)) ;(cdr (assoc 'ICCLE-NB-global-1p-freq v)) (cdr (assoc 'NB-global-1p-freq v)) (cdr (assoc 'MINUS-AVOID-NB-global-1p-freq v)) (cdr (assoc 'WEIGHTED-RANDOM-global-1p-freq v)) (cdr (assoc 'AVOID-WEIGHTED-RANDOM-global-1p-freq v)) (cdr (assoc 'RANDOM-global-1p-freq v)) (cdr (assoc 'MINUS-AVOID-RANDOM-global-1p-freq v)) ;(cdr (assoc 'ICCLE-NB-global-1p-freq v)) ;(cdr (assoc 'NB v)) ;(cdr (assoc 'MINUS-AVOID-NB v)) ;(cdr (assoc 'WEIGHTED-RANDOM v)) ;(cdr (assoc 'AVOID-WEIGHTED-RANDOM v)) ;(cdr (assoc 'RANDOM v)) ;(cdr (assoc 'MINUS-AVOID-RANDOM v)) )) ;local-xp-prob ;global-1p-freq datahash)))))) ;(showh datahash) ;;datahash now holds a hash table where the keys are the dataset names ;;and each value is an associated list where the key is the treatment ;;name and the value is the statistic ;(maphash #'(lambda (k v) ; (setf v (sort v #'> :key #'cdr)) ; (if (= (list-length v) (list-length (remove-duplicates (copy-list v) :key #'cdr :test #'=))) ; (let ((i 0)) ; (setf v (mapcar #'(lambda (x) ; (incf i) ; ; (cons (car x) (cdr x)));Should be i ; v)) ; (setf (gethash k datahash) v)) ; (remhash k datahash))) ; datahash) ;;Any records that had ties(eg: more than one treatment for the recordset ;;had the same statistic) have been removed (only one out of 56 for us) ;;The others have had their statistic replaced with their rank ;(let ((avg (make-hash-table))) ;(maphash #'(lambda (k v) ; (if (some #'(lambda (x) (> (cdr x) 1)) v) ; (mapcar #'(lambda (x) ; (incf (gethash k avg 0) (cdr x))) ;(cdr x)) ; v))) ; datahash) ;;Avg(another hash table) holds the total count of the ranks for the ;;treatments. The keys are the treatments and the value is the sum of ;;the ranks|treatment. ; (maphash #'(lambda (k v) ; (setf (gethash k avg) (fround (/ (gethash k avg) (hash-table-size datahash))))) ; avg) ;;Each value in avg is divided by the number of datasets to give the ;;average rank ;Showing this b/c it is handy to see... No other reason... ;(showh avg) ;(let ((numbers (list))) ; (maphash #'(lambda (k v) ;(push v numbers)) ;avg) ; (print numbers) ;;numbers holds the list of the average ranks ignoring which ;;attribute they come from. This will be used soon... ; (let* ((xf (* (/ (* 12 (hash-table-size datahash)) ; (* (hash-table-size avg) ; (+ (hash-table-size avg) 1))) ; (- (sum (mapcar #'square numbers)) ; (/ (* (hash-table-size avg) ; (square (+ (hash-table-size avg) 1))) ;(hash-table-size avg))))) ;;The above was the first part of the Friedman test ; (ff (/ (* (- (hash-table-size datahash) 1) xf) ; (- (* (- (hash-table-size avg) 1) ; (hash-table-size datahash)) ; xf)))) ;;The above was the second part of the Friedman test ; (format t "~%~%==============~%The Friedman magical number must be greater less than: ~A~%~%" ff) ; (format t "Look up the magical value from the table at loc(~A, ~A)~%~%" ; (- (hash-table-size avg) 1) ; (* (- (hash-table-size avg) 1) (- (hash-table-size datahash) 1))) ; (format t "The magical values are at~%") ; (format t "http://iccle.googlecode.com/svn/trunk/share/cvs/Fvalue95percent.csv~%=============~%~%"))))))))