Error: The tuning parameter grid should have columns fL, usekernel, adjust. K fold Cross Validation

Error: The tuning parameter grid should have columns fL, usekernel, adjust. K fold Cross Validation

我该如何解决这个问题 error.I 我自己尝试解决了这个错误,但仍然没有成功,有人能帮助我吗?

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)

我收到这个错误:

Error: The tuning parameter grid should have columns fL, usekernel, adjust

如错误中所述,您缺少一个调整参数 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