简体   繁体   中英

How to fix “The metric ”Accuracy“ was not in the result set. AUC will be used instead”

I am trying to run a logistic regression on a classification problem

the dependent variable "SUBSCRIBEDYN" is a factor with 2 levels ("Yes" and "No")

train.control <- trainControl(method = "repeatedcv",
number = 10,
repeats = 10,
verboseIter = F,
classProbs = T,
summaryFunction = prSummary)

set.seed(13)
simple.logistic.regression <- caret::train(SUBSCRIBEDYN ~ .,
data = train_data,
method = "glm",
metric = "Accuracy",
trControl = train.control)


simple.logistic.regression`

However, it does not accept Accuracy as a metric "The metric "Accuracy" was not in the result set. AUC will be used instead"

For a classification model with 2 levels, you should use metric="ROC" . metric="Accuracy" is used for multiple classes. However, after training the model, you can use the confusion matrix to retrieve the accuracy, for example using the function confusionMatrix() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM