出了点问题;所有准确性指标值都缺失:模型验证
Something is wrong; all the Accuracy metric values are missing: model validation
我想运行此代码用于模型验证,但我在 train()
中遇到错误
library(caret)
diabet<-read.csv("C:/Users/Downloads/diabetes.csv")
diabet$Outcome<-as.factor(diabet$Outcome)
diabet$BMI<-as.factor(diabet$BMI)
train_control<- trainControl(method="boot", number=100)
model <-train(diabet$Outcome~diabet$BMI, trControl=train_control, method="nb")
print(model)
我遇到了这种类型的错误
Something is wrong; all the Accuracy metric values are missing:
Accuracy Kappa
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :2 NA's :2
Error: Stopping
In addition: There were 50 or more warnings (use warnings() to see the first 50)
谁能帮我解决这个错误?
根据the documentation,有两种调用train()
的方法:
## S3 method for class 'default':
train(x, y,
method = "rf",
...,
weights = NULL,
metric = ifelse(is.factor(y), "Accuracy", "RMSE"),
maximize = ifelse(metric == "RMSE", FALSE, TRUE),
trControl = trainControl(),
tuneGrid = NULL,
tuneLength = 3)
## S3 method for class 'formula':
train(form, data, ..., weights, subset, na.action, contrasts = NULL)
根据你的问题 post,你似乎在尝试使用第二个签名,所以你应该如何实现它:
model <-train(Outcome~BMI, data=diabet, trControl=train_control, method="nb")
这样您就有了 form
的有效公式,并且您还在函数调用中传入了所需的 data
。
我想运行此代码用于模型验证,但我在 train()
中遇到错误library(caret)
diabet<-read.csv("C:/Users/Downloads/diabetes.csv")
diabet$Outcome<-as.factor(diabet$Outcome)
diabet$BMI<-as.factor(diabet$BMI)
train_control<- trainControl(method="boot", number=100)
model <-train(diabet$Outcome~diabet$BMI, trControl=train_control, method="nb")
print(model)
我遇到了这种类型的错误
Something is wrong; all the Accuracy metric values are missing:
Accuracy Kappa
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :2 NA's :2
Error: Stopping
In addition: There were 50 or more warnings (use warnings() to see the first 50)
谁能帮我解决这个错误?
根据the documentation,有两种调用train()
的方法:
## S3 method for class 'default':
train(x, y,
method = "rf",
...,
weights = NULL,
metric = ifelse(is.factor(y), "Accuracy", "RMSE"),
maximize = ifelse(metric == "RMSE", FALSE, TRUE),
trControl = trainControl(),
tuneGrid = NULL,
tuneLength = 3)
## S3 method for class 'formula':
train(form, data, ..., weights, subset, na.action, contrasts = NULL)
根据你的问题 post,你似乎在尝试使用第二个签名,所以你应该如何实现它:
model <-train(Outcome~BMI, data=diabet, trControl=train_control, method="nb")
这样您就有了 form
的有效公式,并且您还在函数调用中传入了所需的 data
。