在R中绘制C5.0树

App*_*te0 7 r

我试图在R中绘制一个C5.0对象树,但它给出了以下错误,我似乎无法找到如何解决它.

plot(model)

Error in partysplit(varid = as.integer(i), index = index, info = k, prob = NULL)   : 
 minimum of ‘index’ is not equal to 1
In addition: Warning message:
In min(index, na.rm = TRUE) :
 no non-missing arguments to min; returning Inf
Run Code Online (Sandbox Code Playgroud)

Nan*_*tel 0

您的数据框中的因素似乎包含空格。我遇到了同样的问题,然后我删除了它们中的空格,现在它可以工作了。例如,如果变量具有“坏”和“好”因素,则将它们更改为“坏”和“好”。

“错误本身是由于在索引向量中传递 NA 值造成的。根本原因可能是因子水平在空间上被分割”在这里找到https://github.com/topepo/C5.0/issues/10