我正在尝试导出由R中的c50包构建的模型。
我使用partykit包提取最后一个试验,但它没有返回相同的拟合值。
我不明白为什么as.party.c5.0函数和C5.0函数的拟合方式不完全一样。它适用于第一个试验,但不适用于其他试验。
例如:
poc_db<-iris
fullTree_prun_iris_Winow <- C5.0(Species ~ ., data =poc_db, trials = 10,control = C5.0Control(CF = 0.90,noGlobalPruning = FALSE,winnow = T))
cat(fullTree_prun_iris_Winow$output)
----- Trial 9: -----
Decision tree:
Petal.Width <= 0.6: setosa (10.5)
Petal.Width > 0.6:
:...Petal.Width <= 1.7: versicolor (116.3/49.4)
Petal.Width > 1.7: virginica (22.2)
modParty <- C50:::as.party.C5.0(fullTree_prun_iris_Winow,trial=10)
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: versicolor (n = 54, err = 9.3%)
| | [5] Petal.Width > 1.7: virginica (n = 46, err = 2.2%)我们应该有第四个节点:...杂色(116/49)
感谢你的帮助
发布于 2017-07-07 02:37:54
第四个节点有54个观察值,其中49个是杂色的。看见
table(subset(poc_db, Petal.Width > 0.6 & Petal.Width <= 1.7)$Species)
## setosa versicolor virginica
## 0 49 5 因此,partykit报告对应于5/54的n = 54和err = 9.3%。C5.0报告的值是不同的,因为它是通过多次试验来提升树的,而不是仅仅使用一棵树本身。
https://stackoverflow.com/questions/44949920
复制相似问题