;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Assignment 6 Problem 3 ; ; Here's some information on how I solved this problem (in order to ; see how well you could do with this problem.) BTW, my code for this ; problem discretizes all 30 attributes using a single threshold for ; each attribute. I wrote it in 80 lines (including comments) in ; about an hour. ; ; ; I wrote a the following function which automatically generates a ; discretize procedure. I'm not giving you all the other procedures ; that this one calls, but you can get the general idea of my approach ; from this. ; ; (define (create-discretize-fn tdata) ; find thresholds for n elements (0 through n-1) and return a list of them (define (find-thresholds i n) (if (= i n) '() (cons (find-best-threshold-val tdata i) (find-thresholds (+ i 1) n)))) (let ((thresh-list (find-thresholds 0 (length (second (first tdata)))))) (display "Here is the list of threshold values:\n") (display thresh-list) ; print out the list so I can see it ; here's my discretize procedure (lambda (ex) (map (lambda (a b) (if (>= a b) 'high 'low)) ex thresh-list)))) ; one of the procedures I wrote picks the best threshold value using ; the procedure we discussed in class. ; (find-best-threshold-val bc-data-s 9) ;Value: .05915 ; Now I'll run my create-discretize-fn on two of the training data sets... ; (define discretize-fn (create-discretize-fn bc-data-l1)) Here is the list of threshold values: ; I deleted the values that were printed here so I'm not just giving you ; the answer! ;Value: discretize-fn ; The function that would go in my file to turn in for problem 3 would ; simply take the values printed out above and hardcode them into my ; discretize function. (define (discretize attribute-values) (let ((thresh-list ; I inserted values from above here!)) (map (lambda (a b) (if (>= a b) 'high 'low)) attribute-values thresh-list))) ; learn a decision tree using the discretize procedure... (define dt (ldt-disc discretize bc-data-l1)) ;Value: dtr1 ; if you've got the latest version of the a6code, you can turn of all ; the printing that would normally appear by setting the following variable (define print-info #f) ;Value: print-info ; now test the decision tree on another data set (testdt-disc discretize dt bc-data-l3) ;Value 26: (194 200) ; it correctly classified 194 out of 200 examples...