here is my code:
train <- data.frame(***contain label, feature group 1 and feature group 2***)
formula <- label ~ features group 1
ctrl <- trainControl(method = "repeatedcv",
number = 10,
repeats = 5,
summaryFunction = twoClassSummary,
classProbs = T)
fit <- train(formula,
data = train,
method = "glm",
metric = "ROC",
trControl = ctrl,
na.action = na.omit)
pred <- predict(fit, train)
my question is: How to calculate the AUC of pred
?
I ve tried prSummary, ROCR and pROC, didn't work, it seems like that I can not calculate AUC when both of the obs and pred are exactly the same(levels-wise).
I m wondering if I can train with AUC as metric, how can I can't show the AUC?
p.s.
> levels(train$label)
[1] "classA" "classB"
> levels(as.factor(pred))
[1] "classA" "classB"
btw what I am doing is: fit multiple algo with caret and rank them by AUC, then I can choose the optimal one (base on AUC).
*reproducible example:
train set: iris
feature g1: first 2 features
feature g2: last 2 features
seed: 123*