简体   繁体   English

需要帮助解决决策树中的错误打印培训和测试结果

[英]Need help resolving error printing training and test results in from decision tree

`setwd("C:/Users/rsiky/Documents/summer2021/week2/cvs_files")
 credit <- read.csv(file="CreditApproval.csv", head=TRUE, sep=",", 
 stringsAsFactors = TRUE)
 # Review Structure of dataset
 str(credit)

# Load libraries
# Discretize
summary(credit$A2); credit$A2<-discretize(credit$A2, "frequency", breaks=6); 
summary(credit$A2)
summary(credit$A3); credit$A3<-discretize(credit$A3, "frequency", breaks=6); 
summary(credit$A3)
summary(credit$A8); credit$A8<-discretize(credit$A8, "frequency", breaks=6); 
summary(credit$A8)
summary(credit$A11); credit$A11<-discretize(credit$A11, "interval", 
breaks=6); summary(credit$A11)
summary(credit$A14); credit$A14<-discretize(credit$A14, "interval", 
breaks=6); summary(credit$A14)
summary(credit$A15); credit$A15<-discretize(credit$A15, "interval", 
breaks=6); summary(credit$A15)
credit$A3<-factor(credit$A3)
summary(credit$A3)
set.seed(1234)
ind <- sample(2, nrow(credit), replace = TRUE, prob = c(0.7, 0.3))
train.data <- credit[ind == 1, ]
test.data <- credit[ind == 2, ]
myFormula<-A3~.
credit__ctree<-ctree(myFormula, data = train.data)
print(credit_ctree)`

When I run the print command I get the following error:当我运行打印命令时,出现以下错误:

Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'print': object 'credit_ctree' not found h(simpleError(msg, call)) 中的错误:在为 function 'print' 选择方法时评估参数 'x' 时出错:未找到 object 'credit_ctree'

How do I resolve this error?如何解决此错误?

The problem was a typo in the second to last line问题是倒数第二行的错字

credit__ctree<-ctree(myFormula, data = train.data) print(credit_ctree)` credit__ctree<-ctree(myFormula, data = train.data) print(credit_ctree)`

as you can see there is an extra underscore I had credit__ctree and it should have been credit_ctree如您所见,我有一个额外的下划线 credit__ctree 应该是 credit_ctree

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM