I would like to plot the result of an ID3 model. It doesn't seem to have a default plot module in WEKA nor in R.
Is there an already made code to do this? (or, does the tree format below has a standard name, for which I could easily find a parser?)
Here is some basic code:
# I'm getting a post from this: https://en.wikipedia.org/wiki/ID3_algorithm
## load RWeka
if(!require(RWeka)) install.packages("RWeka")
library(RWeka)
## look for a package providing id3
WPM("refresh-cache")
WPM("list-packages", "available") ## look for id3
## install package providing id3
WPM("install-package", "simpleEducationalLearningSchemes")
## load the package
WPM("load-package", "simpleEducationalLearningSchemes")
## make classifier
ID3 <- make_Weka_classifier("weka/classifiers/trees/Id3")
## test it out.
DF2 <- read.arff(system.file("arff", "contact-lenses.arff",
package = "RWeka"))
ID3(`contact-lenses` ~ ., data = DF2)
Here is the result:
Id3
tear-prod-rate = reduced: none
tear-prod-rate = normal
| astigmatism = no
| | age = young: soft
| | age = pre-presbyopic: soft
| | age = presbyopic
| | | spectacle-prescrip = myope: none
| | | spectacle-prescrip = hypermetrope: soft
| astigmatism = yes
| | spectacle-prescrip = myope: hard
| | spectacle-prescrip = hypermetrope
| | | age = young: hard
| | | age = pre-presbyopic: none
| | | age = presbyopic: none
The tree structure is very easy to understand. Any suggestions on how to go about parsing this one? (maybe similar to the answer from here?)
Thanks.