How do you calculate the model accuracy in RStudio for logistic regression. The dataset is from Kaggle.
set.seed(1000)
split = sample.split(query$Exited, SplitRatio = 0.65)
train = subset(query, split==TRUE)
test = subset(query, split==FALSE)
model = glm(Exited ~ CreditScore + Gender + Age + Balance + IsActiveMember, data = train, family=binomial)
summary(model)
predict = predict(model, type="response", newdata=test)
table(test$Exited, predict > 0.5)
FALSE TRUE
0 2717 70
1 606 107
Is it possible to extract the values from the table to calculate the accuracy using variables or is there a function to get the accuracy?
# Accuracy of model:
(2717+107)/(2717+70+606+107)
Is it more accurate? I'm getting different values.
(2717+107)/(2717+70+606+107)
accuracy is 0.8068571
Accuracy(y_pred = pred, y_true = train$Exited)
accuracy is 0.8087692 using ML metrics