错误:调整参数网格应包含fL、usekernel和adjust列。K折叠交叉验证

错误:调整参数网格应包含fL、usekernel和adjust列。K折叠交叉验证,r,data-science,r-caret,R,Data Science,R Caret,我如何修复这个错误。我试图自己修复这个错误,但是失败了。有人能帮我吗 library(caret) diabet<-read.csv(file.choose(),header = T,sep=",") diabet$Outcome<-as.factor(diabet$Outcome) # define training control train_control<- trainControl(method="cv", number=10)

我如何修复这个错误。我试图自己修复这个错误,但是失败了。有人能帮我吗

library(caret)
diabet<-read.csv(file.choose(),header = T,sep=",")
diabet$Outcome<-as.factor(diabet$Outcome)
# define training control
train_control<- trainControl(method="cv", number=10)
# fix the parameters of the algorithm
grid <- expand.grid(.fL=c(0), .usekernel=c(FALSE))
# train the model
model <- train(Outcome~BMI, data=diabet,
                trControl=train_control, method="nb", tuneGrid=grid)
# summarize results
print(model)

如错误中所述,缺少一个调整参数
adjust
。你可以这样看:

getModelInfo("nb")$nb$parameters
  parameter   class                label
1        fL numeric   Laplace Correction
2 usekernel logical    Distribution Type
3    adjust numeric Bandwidth Adjustment
如果您将其包括在内,则应:

library(caret)
diabet = data.frame(Outcome = sample(c("Yes","No"),100,replace=TRUE),
                    BMI = runif(100))

train_control<- trainControl(method="cv", number=10)
grid <- expand.grid(.fL=c(0), .usekernel=c(FALSE),.adjust=0.5)

model <- train(Outcome~BMI, data=diabet,
                trControl=train_control, method="nb", tuneGrid=grid)

Naive Bayes 

100 samples
  1 predictor
  2 classes: 'No', 'Yes' 

No pre-processing
Resampling: Cross-Validated (10 fold) 
Summary of sample sizes: 90, 90, 91, 90, 90, 90, ... 
Resampling results:

  Accuracy   Kappa     
  0.4187879  -0.1685569

Tuning parameter 'fL' was held constant at a value of 0
Tuning
 parameter 'usekernel' was held constant at a value of FALSE
Tuning
 parameter 'adjust' was held constant at a value of 0.5
库(插入符号)
diabet=data.frame(结果=样本(c(“是”、“否”),100,替换=真),
BMI=runif(100))

列车控制如错误中所述,缺少一个调谐参数
adjust
。你可以这样看:

getModelInfo("nb")$nb$parameters
  parameter   class                label
1        fL numeric   Laplace Correction
2 usekernel logical    Distribution Type
3    adjust numeric Bandwidth Adjustment
如果您将其包括在内,则应:

library(caret)
diabet = data.frame(Outcome = sample(c("Yes","No"),100,replace=TRUE),
                    BMI = runif(100))

train_control<- trainControl(method="cv", number=10)
grid <- expand.grid(.fL=c(0), .usekernel=c(FALSE),.adjust=0.5)

model <- train(Outcome~BMI, data=diabet,
                trControl=train_control, method="nb", tuneGrid=grid)

Naive Bayes 

100 samples
  1 predictor
  2 classes: 'No', 'Yes' 

No pre-processing
Resampling: Cross-Validated (10 fold) 
Summary of sample sizes: 90, 90, 91, 90, 90, 90, ... 
Resampling results:

  Accuracy   Kappa     
  0.4187879  -0.1685569

Tuning parameter 'fL' was held constant at a value of 0
Tuning
 parameter 'usekernel' was held constant at a value of FALSE
Tuning
 parameter 'adjust' was held constant at a value of 0.5
库(插入符号)
diabet=data.frame(结果=样本(c(“是”、“否”),100,替换=真),
BMI=runif(100))

培训控制如果您包含一个简单的示例输入和所需的输出,可以用来测试和验证可能的解决方案,那么就更容易为您提供帮助。从错误消息来看,您似乎缺少
网格中的
adjust
列。如果您包含一个简单的示例输入和所需的输出,可用于测试和验证可能的解决方案,则更容易为您提供帮助。从错误消息中,您似乎缺少
网格中的
调整