I am a newbie to data science and ML. I am working on a classification problem where the task is to predict loan status (granted/not granted).

I am running a logistic regression model on the data. The accuracy of my model is 82%. However, my model is more sensitive (sensitivity = 97%) and less specific(specificity = 53%).

I want to increase the model's specificity. At this stage, after referring to a bunch of internet resources, I am confused about how to proceed.

Below is my observation : In Testing data,

a percentage of 1's in the class label is 73.17073170731707.

Testing data has more 1's than 0's in the class label. Is this the reason behind model being highly sensitive.

I am attaching my data file and code file. Please take a look at it.

Data sample :

data sample

Process : Data --> missing value imputation -->distribution analysis-->log transformation for normal distribution ---> one hot encoding --> feature selection --> splitting data --> model selection and evaluation

Code snippets :

feature selection

Here I have selected "3 best features": Credit History, Property Area

model evaluation

How should I proceed? Any help (even if it's just a kick in the right direction) would be appreciated.

  • $\begingroup$ Can you share some instances of the data? Perhaps there are more appropriate models than a logistic regression. Also you can weight the loss caused by 1's more heavily. $\endgroup$
    – JahKnows
    Commented Apr 6, 2019 at 18:03
  • $\begingroup$ The Google Drive link will sooner or later be dead. Keep in mind that your question may be useful for somebody in the future. So, could you please add some sample lines of your data and the relevant code snippets to your question. $\endgroup$
    – georg-dev
    Commented Apr 6, 2019 at 18:38
  • 1
    $\begingroup$ @georg_un I have updated the question. $\endgroup$
    – blueWings
    Commented Apr 6, 2019 at 19:11
  • $\begingroup$ @JahKnows I have tried SVM with RBF kernel. But still, I am getting the same sensitivity and specificity. Also, I didn't get intuition behind weighting the loss by 1's $\endgroup$
    – blueWings
    Commented Apr 6, 2019 at 19:30

2 Answers 2


Actually, what is happening is natural. There is a trade-off between sensitivity and specificity. If you want to increase the specificity, you should increase the threshold of your decision function but note that it comes at a price and the price is reducing the sensitivity.

  • $\begingroup$ @blueWings You’re welcome. So, have you tried changing the threshold? $\endgroup$
    – pythinker
    Commented Apr 6, 2019 at 19:49
  • $\begingroup$ Yes. I set the threshold to 0.7 and now my specificity increased to 57%. But as you said it came with less sensitivity that is 82%. ROC remained same 0.70. $\endgroup$
    – blueWings
    Commented Apr 6, 2019 at 19:59
  • $\begingroup$ @blueWings ROC/AUC is created by evaluating across a spectrum of thresholds, not at one threshold, so if ROC didn't remain the same, that would mean you had a bug in your code. $\endgroup$
    – Dave
    Commented Sep 24, 2021 at 15:00

Just an idea. Have you tried 'playing' with C?

C is the inverse of regularization strength. Large values of C give more freedom to the model. Default C is 1.

A high C like 1000 can (not always) give you a higher variance and lower bias while you might overfit though. Good luck! Logistic Regression

  • $\begingroup$ I haven't. Thank you for useful insights. $\endgroup$
    – blueWings
    Commented Apr 7, 2019 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.