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

时间:2021-03-29 15:56:22

标签: r rpart

以下取自 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

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

0 个答案:

没有答案
相关问题