(defklass abcd () (a 0) (b 0) (c 0) (d 0) acc prec pd pf f g balance support target) (defmethod print-object ((x abcd) str) (abcd-report x) (in abcd x (format str "| ~5s, ~a, ~a, ~a, ~a, ~a" target (p pd) (p pf) (p prec) (p f) (p acc)))) (defun abcd-reports (results) "Update all fields in a hash of abcd" (dovalue (result results results) (abcd-report result))) (defun abcd-report (result) (in abcd result (setf acc (/ (+ a d) (+ *zip* a b c d)) support (/ (+ c d) (+ *zip* a b c d)) pf (/ c (+ *zip* a c )) prec (/ d (+ *zip* c d )) pd (/ d (+ *zip* b d )) f (/ (* 2 prec pd) (+ *zip* prec pd)) g (/ (* 2 pd (1- pf)) (+ *zip* pd (1- pf))) balance (/ (- 1 (sqrt (+ (expt (- 1 pf) 2) (expt pd 2)))) (sqrt 2))) result)) (defun classes->abcd (h) "For each class, generate one place to store abcd" (let ((out (make-hash-table))) (dokeys (class h out) (setf (gethash class out) (make-instance 'abcd :target class))))) (defun abcd-add (all actual predicted) (dohash (target result all all) (in abcd result (if (eql actual target) (if (eql predicted actual) (incf d) (incf b)) (if (eql predicted target) (incf c) (incf a))))))