Caret Error: "All the Accuracy Metric Values Are Missing"

Something is wrong; all the Accuracy metric values are missing: model validation

As per the documentation, there are two ways to call the 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)

From your question post, it looks like you're attempting to use the second signature, so this is how you should be implementing it:

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

This way you have a valid formula for form, and you also pass in the required data in the function call.

Something is wrong; all the RMSE metric values are missing; using caret train function

You are doing a classification, so you need to set the dependent variable to a factor for train in caret to work:

set.seed(123)
fitControl = trainControl(method="cv", number=5, returnResamp = "all")

mydata$Site = factor(mydata$Site)

model2 = train(Site~., data=mydata[complete.cases(mydata),], method="gbm",distribution="bernoulli", trControl=fitControl, verbose=F, tuneGrid=data.frame(.n.trees=400, .shrinkage=0.01, .interaction.depth=1, .n.minobsinnode=1))

model2

Stochastic Gradient Boosting

234 samples
9 predictor
2 classes: '0', '1'

No pre-processing
Resampling: Cross-Validated (5 fold)
Summary of sample sizes: 187, 187, 187, 188, 187
Resampling results:

Accuracy Kappa
0.9232192 0.5550649

Tuning parameter 'n.trees' was held constant at a value

Tuning parameter 'n.minobsinnode' was held constant at
a value of 1


Related Topics



Leave a reply



Submit