Just trying to practice a logistic regression with a binary outcome. Decided to just try take the Iris dataset without 'versicolor' But when i try to train a model it gives an error: "error: One or more factor levels in the outcome has no data: 'versicolor'"
I don't get it i thought i excluded this! There is something fundamental i clearly don't get. What don't i understand? Thank you.
library(dplyr)
test_iris <- iris %>%
select (everything()) %>%
filter(Species != "versicolor")
myFolds <- createFolds(test_iris, k = 5)
myControl <- trainControl(
summaryFunction = twoClassSummary,
classProbs = TRUE,
verboseIter = TRUE,
savePredictions = TRUE,
index = myFolds)
library(caret)
model1 <- train(
Species ~.,test_iris,
metric = "ROC",
method = "glm",
family = binomial,
trControl = myControl
)