;;; -*- Mode: LISP; Syntax: Common-lisp; Package: USER; Base: 10 -*- ; ;****************************************************************************** ; ; AUTOCLASS II - Automatic Classification of Data ; ; Authors : Peter Cheeseman - RIACS - Research Institute for Advanced ; Computer Science ; Matthew Self - Sterling Software ; ; John Stutz - RIA - Artificial Intelligence Research Branch ; ; William Taylor - Sterling Software ; ; Address : MS 244-17, NASA Ames Research Center, Moffett Field, CA 94035 ; ; Phone : (415) 694-4946 - FTS 464-4946 ; ; Arpanet : taylor%plu@io.arc.nasa.gov ; ; Environment : Common Lisp ; ; Revision History : 11 Jan 88 - original released version - ; ;****************************************************************************** ; ;****************************************************************************** ; ; FILE : cha:>taylor>autoclass-x>nograph-ui>metrics-pane.lisp ; ; Description : Build metrics pane in display window for AUTOCLASS II - automatic class discovery from data ; ; Functions defined : GENERATE-METRICS-REPORT ; METRICS-REPORT-HEADER ; METRICS-GLOBAL-ATTRIBUTE-INFLUENCE ; METRICS-CLASS-WEIGHTS ; METRICS-REPORT-CLASS ; METRICS-REPORT-ATTRIBUTES ; ; Environment : Symbolics 3640 - Genera 7.0 - Common Lisp ; ; Author : Will Taylor - Sterling Software ; ; Revision History : 20 Apr 87 - original version ; 05 Jan 88 - For no graph UI => delete flavor & modify ; methods to functions ; ;****************************************************************************** ; ;;; ;;;******************************************************* ;;; (defun GENERATE-METRICS-REPORT (metrics-report-file) "report metrics of all classes " (with-open-file (stream metrics-report-file :direction :output) ;;(let ((stream t)) (let ((classes-array (part-classes *partition*))) (metrics-report-header stream) (dolist (n-class *class-wt-ordering*) (when (>= (class-wt (aref classes-array n-class)) 1.0) (metrics-report-class n-class stream) (format stream "~|")))))) ;;; ;;;******************************************************* ;;; (defun METRICS-REPORT-HEADER (stream) "report metrics header" (format stream "~%AutoClass classification for the ~A cases in ~%~A, ~%using the ~A MML classification in ~%~A. ~2%" *n-data* *current-db* (part-total-mml *partition*) *current-results*) (format stream (concatenate 'string "~%The metrics for the classification consist of the influence values for each attribute" "~%expressed as I-jkl, where j is the class index, k is the attribute index and l is the" "~%value index for discrete attributes. First is an ordered list of the attribute influence" "~%values summed over all classes, indicating the relative influence of each attribute" "~%to the overall classification. Following that is an ordered class list (by class weight)" "~%of ordered attribute influence values for each class, indicating the relative influence" "~%of each attribute to that class. The discrete (type = d) attribute influence values consist" "~%of the summation over all values (l) of a form involving the probability of the attribute" "~%for that class (P-jkl) and the global probability for all classes (P*-kl). The" "~%real (type = r) attribute influence values consist of a form involving the mean and" "~%standard deviation for that class (Mean-jk, Stdv-jk); the global mean and global" "~%standard deviation (Mean*-k, Stdv*-k) and the probability of unknown values for that" "~%class (PU-jk), the probability of known values for that class (PK-jk) and their global" "~%counterparts (PU*-k, PK*-k).~2%")) (metrics-global-attribute-influence stream) (metrics-class-weights stream)) ;;; ;;;******************************************************* ;;; (defun METRICS-GLOBAL-ATTRIBUTE-INFLUENCE (stream) "report sorted list of attribute influence values over all classes" (let ((output ())) (format stream "~%Ordered list of normalized attribute influence values summed over all classes ~2%") (format stream (format nil "num type description I-k ~%" *influence-sum-max*)) (dotimes (N-var *n-variables*) (let ((description (nth N-var *variable-descriptions*))) (setf output (cons (list (aref *influence-sums* N-var) (format nil "~%~3D: ~A ~20A ~6,3F" N-var (string-downcase (subseq (string (nth N-var *variable-types*)) 0 1)) (subseq description 0 (min 20 (length description))) (/ (aref *influence-sums* N-var) *influence-sum-max*))) output)))) (dolist (sublist (sort output #'> :key #'first)) (format stream (second sublist))) (format stream "~|"))) ;;; ;;;******************************************************* ;;; (defun METRICS-CLASS-WEIGHTS (stream) "report ordered list of normalized class weights" (let ((classes-array (part-classes *partition*)) (populated-classes-cnt 0)) (dotimes (N-class (length classes-array)) (if (>= (class-wt (aref classes-array N-class)) 1.0) (setf populated-classes-cnt (1+ populated-classes-cnt)))) (format stream "~3%PARTITION HAS ~A POPULATED CLASSES: (max class influence value = ~5,3F) ~2%" populated-classes-cnt *influence-value-max*) (format stream "~% class num weight normalized weight (total weight = ~4,1F) ~2%" (part-memb-wt *partition*)) (dotimes (indx populated-classes-cnt) (let ((wt (class-wt (aref classes-array (nth indx *class-wt-ordering*))))) (format stream "~% ~6D ~3,1F ~4,2F" indx wt (/ wt (part-memb-wt *partition*))))) (format stream "~|"))) ;;; ;;;******************************************************* ;;; (defun METRICS-REPORT-CLASS (N-class stream) "Reports class weight, and the accumulater values normalized into probabilities by dividing by class weight." (let* ((class-obj (aref (part-classes *partition*) N-class)) (class-wt (class-wt class-obj))) (format stream "~2%CLASS ~A - weight ~3,1F - normalized weight ~4,2F **************************************~%" (position N-class *class-wt-ordering*) class-wt (/ class-wt (part-memb-wt *partition*))) (format stream "~%ATTRIBUTES: TYPE = D (DISCRETE)") (format stream "~%num type description Ijk ( l P-jkl P*-kl), l = 0,1,2... ") (format stream "~%ATTRIBUTES: TYPE = R (REAL-PT)") (format stream "~%num type description Ijk (Mean-jk Mean*-k) (Stdv-jk Stdv*-k) (PU-jk PU*-k) (PK-jk PK*-k)~2%") (metrics-report-attributes N-class stream) (format stream "~|"))) ;;; ;;;******************************************************* ;;; (defun METRICS-REPORT-ATTRIBUTES (N-class stream) "Reports the accumulater variable/values stored in the accumulater acc. the values are reported as probabilities, that is weight/total-wt." (let ((output ()) (header nil)) (do ((N-var 0 (1+ N-var)) (types *variable-types* (rest types)) (descriptions *variable-descriptions* (rest descriptions))) ((= N-var *N-variables*)) (setf header (format nil "~3D: ~A ~20A" N-var (string-downcase (subseq (string (first types)) 0 1)) (subseq (first descriptions) 0 (min 20 (length (first descriptions)))))) (let ((influence-values (aref (aref *influence-values* N-class) N-var))) (case (first types) (discrete (push (list (i-discrete-value influence-values) header (format nil " ~6,3F ~{(~{~2D ~4,3F ~4,3F~}) (~{~2D ~4,3F ~4,3F~}) (~{~2D ~4,3F ~4,3F~}) (~{~2D ~4,3F ~4,3F~}) ~^~%~41T~} ~%" (i-discrete-value influence-values) (i-discrete-p-p*-list influence-values))) output)) (real-pt (push (list (i-real-pt-value influence-values) header (format nil " ~6,3F ~{(~{~6,2F ~6,2F~}) (~{~6,2F ~6,2F~}) (~{~4,3F ~4,3F~}) (~{~4,3F ~4,3F~})~} ~%" (i-real-pt-value influence-values) (i-real-pt-mean-sigma-list influence-values))) output)) (ignore ) (t (break "bad type - ~A" (first types)))))) (setf output (sort output #'> :key #'first)) (let ((reduced-list ())) (dolist (sub output) (setf reduced-list (cons (third sub) (cons (second sub) reduced-list)))) (format stream (apply 'concatenate (cons 'string (reverse reduced-list))))))) ;;; ;;;******************************************************* ;;;