0

I've managed to build a logistic model, yet when I've tried to find its accuracy (i.e. sensitivity and specificity) I got this error: sensitivity.default(test$FL_CLI_USES_BANK_APP_M, predicted, threshold = 0.5): inputs must be factors. If anyone has any ideas where I have made a mistake please let me know, the code is below plus I'm attaching a screenshot. Thanks in advance.

smp_size <- floor(0.75 * nrow(GBAC_NOPASS))
train_ind <- sample(seq_len(nrow(GBAC_NOPASS)), size = smp_size)
train <- GBAC_NOPASS[train_ind, ]
test <- GBAC_NOPASS[-train_ind, ]
logitMod <-glm(FL_CLI_USES_BANK_APP_M~ CD_GENDER + QT_AGE +FL_CLI_HAS_ACCT_MANAGER + FL_DIGITAL_STATEMENT+CD_NPS_3M + FL_DOES_ECOMMERCE_M+ FL_IS_ETRAVEL_M+ FL_IS_REGULAR_SAVER_M+ FL_USES_REVOLUT_M+ FL_USES_MBWAY_M+FL_USES_ESCOOTER_M+ FL_IS_ESHOPPER_M+ QT_CARDS_M+QT_CURRENT_ACCT_M+ QT_OPER_BRANCH_3M+ QT_OPER_CALLCENTER_3M+ QT_OPER_ATM_3M+ QT_OPER_DIGITAL_3M+ QT_OPER_OTHERS_3M+ FL_CLI_USES_BANK_WEB_M+ QT_TRANSACTIONS_WEB_3M , data=train, family=binomial)
summary(logitMod)
test$FL_CLI_USES_BANK_APP_M <- predict(logitMod, newdata = test, type = "response")
predicted <- predict(logitMod, newdata=test)
sensitivity(test$FL_CLI_USES_BANK_APP_M, predicted, threshold = 0.5)

screenshot

  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Explicitly list any non-base R packages that you are using. – MrFlick Nov 02 '20 at 20:31
  • Packages are dplyr, caret and readr. I can't exactly post the data here cause it is not from the open-source, but basically, FL_CLI_USES_BANK is a numerical variable with a range 0-1, and I'm building a logit model to predict its values. The mistake I described happened not only with the full regression but with a very simple one as well (i.e. FL_CLI_USES_BANK_APP_M~ QT_AGE). – ProjectAvatar Nov 03 '20 at 07:34

0 Answers0