【发布时间】:2020-03-14 14:44:25
【问题描述】:
谁能解释我如何从 RWeka 包中获得 J48 生成的决策树中每次休假的结果?
例如,我们在 R 中有这个 iris 数据集:
library(RWeka)
m1 <- J48(Species ~ ., data = iris)
m1
在预测中,我想使用休假中的比例。我尝试使用 Partykit 包,但它仍然看起来很复杂,只是为了得到每个假期的比例。
library(partykit)
pres <- as.party(m1)
partykit:::.list.rules.party(pres)
至少我得到了列表中的叶子数,但是找不到概率。
pres
Model formula:
Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width
Fitted party:
[1] root
| [2] Petal.Width <= 0.6: setosa (n = 50, err = 0.0%)
| [3] Petal.Width > 0.6
| | [4] Petal.Width <= 1.7
| | | [5] Petal.Length <= 4.9: versicolor (n = 48, err = 2.1%)
| | | [6] Petal.Length > 4.9
| | | | [7] Petal.Width <= 1.5: virginica (n = 3, err = 0.0%)
| | | | [8] Petal.Width > 1.5: versicolor (n = 3, err = 33.3%)
| | [9] Petal.Width > 1.7: virginica (n = 46, err = 2.2%)
Number of inner nodes: 4
Number of terminal nodes: 5
因此,作为预测,我想要例如 Petal.Width > 0.6 的新数据点的结果;花瓣宽度 如何获得这些预测?
【问题讨论】:
标签: r decision-tree rweka j48