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
How to Shift X Axis Positions of Two Geoms Relative to Each Other
Change Value to Percentage of Row in R
How to Create a Binary Vector with 1 If Elements Are Part of the Same Vector
Convert Month's Number to Month Name
Change Line Color Depending on Y Value with Ggplot2
In R, How to Split Timestamp Interval Data into Regular Slots
How to Automate Nested Sections in Rmds Which Include Text, Maps and Tables
Making Sure a Function Does Not Use a Global Variable
How to Extract Text from R's Help Command
Caret Error: "All the Accuracy Metric Values Are Missing"
R: Calculate the Number of Occurrences of a Specific Event in a Specified Time Future
Convert Jpg to Greyscale CSV Using R
How to Pass R Variable into SQLdf