About binary logistic regression models -confusing results of confusion matrices.

Dear all,
I fit a binary logistic regression model obtain information on sens, spec, ppv, npv, CA. After this, i perform the 10-fold cross validation of the same model, and somehow my sens, spec, ppv, npv, CA are exactly the same.

My codes look like this:
set.seed(2021)
#Full model
glm_model <- glm(outcome ~ ., df1, family = binomial(link = "logit"))
summary(glm_model)
res_glm_model <- predict(glm_model, df1, type = "response" )
(table(predictedvalue = res_glm_model > 0.5, Actualvalue = df1$outcome ))

#Cross validation of the model.
glm_crossValSettings <- trainControl(method = "cv", number = 10, savePredictions = "final")

crossVal_glm<- train(outcome ~ ., data = df1, family = "binomial",
method = "glm", trControl = glm_crossValSettings, tuneLength = 2)
pred_glm <- predict(crossVal_glm, newdata = df1)

confusionMatrix(data = pred_glm, df1$outcome)

My problem is that the results on (table(predictedvalue = res_glm_model > 0.5, Actualvalue = df1$outcome )) and cross-validated confusionMatrix(data = pred_glm, df1$outcome) are exactly the same.

Where am i Making the mistake?

Thank you for the answer.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.