Fit a Decision Tree classifier to the data; Error in code

我的梦境 提交于 2020-04-22 03:05:49

问题


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))

This is the error I got back:

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

Where did I go wrong?


回答1:


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



来源:https://stackoverflow.com/questions/47190465/fit-a-decision-tree-classifier-to-the-data-error-in-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!