2

我想绘制一个 ID3 模型的结果。它似乎在 WEKA 和 R 中都没有默认的绘图模块。

是否有已经制作的代码来执行此操作?(或者,下面的树格式是否有一个标准名称,我可以很容易地找到一个解析器?)

这是一些基本代码:

# 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)

结果如下:

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

树形结构很容易理解。关于如何解析这个有什么建议吗?(也许类似于这里的答案?)

谢谢。

4

1 回答 1

0

在 Weka 中可视化一棵树的选项已经有一段时间了。也许您使用的是旧版本?Weka 3.6 和 3.7 附带 J48。如果您只关心可视化它,这个问题的答案显示了几种方法:Visualizing Weka classification tree

于 2015-05-01T15:08:02.177 回答