在fancyRpartPlot 中显示观察数量而不是百分比

问题描述

以下取自 here代码在终端节点中显示了 %:

# install if necessary
install.packages('rpart')
install.packages('rattle')
 
# load libraries
library(rpart)
library(rattle)
 
rpart <- rpart(Species ~ .,data=iris,method="class",)
 
rpart
n= 150 
 
node),split,n,loss,yval,(yprob)
      * denotes terminal node
 
1) root 150 100 setosa (0.33333333 0.33333333 0.33333333)  
  2) Petal.Length< 2.45 50   0 setosa (1.00000000 0.00000000 0.00000000) *
  3) Petal.Length>=2.45 100  50 versicolor (0.00000000 0.50000000 0.50000000)  
    6) Petal.Width< 1.75 54   5 versicolor (0.00000000 0.90740741 0.09259259) *
    7) Petal.Width>=1.75 46   1 virginica (0.00000000 0.02173913 0.97826087) *
 
# plot decision tree
fancyRpartPlot(rpart,main="Iris")

enter image description here

您认为可以改为显示绝对观测数吗?谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)