是否有一个库可以提供更好的决策树图片,或者是否有另一种方法可以使我的决策树在 R 中更易于阅读?

Is there a library to provide a better decision tree picture or is there another way to make my decision tree easier to read in R?

我有一个分类模型,使用 c5.0 算法和这样的脚本。 pola = C5.0(train_set[,-8], train_set[,8])

然后我用这个脚本显示决策树。 plot(pola, type="s", main="Decision Tree")

而 post 的结果给出了相互重叠的书写属性,如图中所示。

那么,是否有库可以提供更好的树图片,或者是否有其他方法可以让我的树更易于阅读? 谢谢。

问题看起来是“大小”而不是错误的决策树图。一种选择是将其保存为图像并以更大的尺寸从外部打开。例如类似于:

png(file = 'mytree.png', width = 920, height = 1260)
plot(pola, type="s", main="Decision Tree")
dev.off()
# Open directory with image 
if (.Platform['OS.type'] == "windows"){
    shell.exec(getwd())
} else {
    system(paste(Sys.getenv("R_BROWSER"), getwd()))
}

这当然会做到这一点,您可能需要四处滚动才能看到树的各个部分。

(归功于 this answer,获得通过 R 打开文件资源管理器的灵感)