使决策树分类器适合数据;代码错误 [英] Fit a Decision Tree classifier to the data; Error in code

查看:88
本文介绍了使决策树分类器适合数据;代码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我输入到RStudio中以创建决策树的代码,而 park 是我所在环境中的一个数据框

This is the code I entered into RStudio to create a decision tree, and park is a data frame I have in my environment

people <- park %>%
  select(Subj, Parkinson, fhi, jitter, rap, shimmer, apq, nhr) %>%
  na.omit()
glimpse(people)
tally(~ Parkinson, data = people, format = "percent")  # simple table


################
set.seed(1688)
#############

# Tree with rpart
whoHasPark <- rpart(Parkinson ~ Subj, fhi, jitter,
                        data = people, control = rpart.control(cp = 0.005, minbucket = 30))
whoHasPark
plot(as.party(whoHasPark))

这是我得到的错误back:

This is the error I got back:


xy.coords(x,y,xlabel,ylabel,log)中的错误:

'x '是一个列表,但没有分量'x'和'y'

Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' is a list, but does not have components 'x' and 'y'

我在哪里出错了?

推荐答案

不确定,但这可能是因为您在rpart调用中给出了 Parkinson〜Subj,fhi,jitter (用逗号分隔它们会引发错误)。尝试 +可能会帮助 Parkinson〜Subj + fhi +抖动

Not sure, but that could be because you are giving Parkinson ~ Subj, f jitter(separating them by comma throws an error) in your rpart call. Trying with '+' might help Parkinson ~ Subj + fhi + jitter.

这篇关于使决策树分类器适合数据;代码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆