This will automaticall run your discretize function on the training data and then call your learn-dt procedure.
Akin to the test-dt procedure, this function runs your discretize function on the test data and then tests it with the given decision tree.
Here's an example of using these functions. (Note that you can do the some thing with the non "discretize" versions.)
(define cdt (learn-disc-dt discretize census-tdata)) ;Value: cdt (test-disc-dt discretize cdt census-test1) Out of 50 examples, 34 were correctly classified, 7 were incorrectly classified, and 9 had attribute values not seen before. ;No value
This function takes a tally (such as that produced by the tally-td procedure) and returns the "majority" attribute value. For example:
(tally-td play-tennis-tdata) ;Value: ((no 2) (yes 3)) (pick-majority (tally-td play-tennis-tdata)) ;Value: yes
This function prints out a decision tree in a nice format. The second argument, a list of the names of the attributes is optional. See the section below (on outputs for the sample data sets) for examples of using this function. There should now be no need for you to use the make-readable-dt procedure.
You can basically follow the procedure given in figure 18.7 of our text, except don't use a default value or handle the case where the examples (training data) is empty. This case will never occur because split-td will only create a "split" if there is at least one training example with the given attribute value.
If there are "unknown" attribute values encountered while classifying an example, the classify procedure will return a default value.
(calc-info '((yes 3) (no 2))) ;Value: .9709505944546686
(print-dt (learn-dt play-tennis-tdata)) (1 (normal yes) (high (0 (overcast yes) (sunny no) (rain no)))) ;No value (print-dt (learn-dt play-tennis-tdata) play-tennis-anames) (humidity (normal yes) (high (outlook (overcast yes) (sunny no) (rain no)))) ;No value (print-dt (learn-dt restaurant-tdata) restaurant-anames) (patrons (none no) (full (hungry (no no) (yes (type (burger yes) (italian no) (thai (fri (no no) (yes yes))))))) (some yes)) ;No value (print-dt (learn-dt mushroom-tdata) mushroom-anames) (odor (c p) (p p) (l e) (a e) (f p) (n (cap-color (p e) (b p) (c e) (y p) (e e) (n e) (w (cap-shape (f e) (c p) (x e))) (g e)))) ;No firstname.lastname@example.org