logistic regression : highly sensitive model












2












$begingroup$


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.










share|improve this question









New contributor




blueWings is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $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
    yesterday










  • $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_un
    yesterday






  • 1




    $begingroup$
    @georg_un I have updated the question.
    $endgroup$
    – blueWings
    yesterday










  • $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
    yesterday


















2












$begingroup$


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.










share|improve this question









New contributor




blueWings is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $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
    yesterday










  • $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_un
    yesterday






  • 1




    $begingroup$
    @georg_un I have updated the question.
    $endgroup$
    – blueWings
    yesterday










  • $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
    yesterday
















2












2








2





$begingroup$


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.










share|improve this question









New contributor




blueWings is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




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.







machine-learning logistic-regression






share|improve this question









New contributor




blueWings is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




blueWings is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday







blueWings













New contributor




blueWings is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









blueWingsblueWings

133




133




New contributor




blueWings is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





blueWings is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






blueWings is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • $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
    yesterday










  • $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_un
    yesterday






  • 1




    $begingroup$
    @georg_un I have updated the question.
    $endgroup$
    – blueWings
    yesterday










  • $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
    yesterday




















  • $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
    yesterday










  • $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_un
    yesterday






  • 1




    $begingroup$
    @georg_un I have updated the question.
    $endgroup$
    – blueWings
    yesterday










  • $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
    yesterday


















$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
yesterday




$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
yesterday












$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_un
yesterday




$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_un
yesterday




1




1




$begingroup$
@georg_un I have updated the question.
$endgroup$
– blueWings
yesterday




$begingroup$
@georg_un I have updated the question.
$endgroup$
– blueWings
yesterday












$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
yesterday






$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
yesterday












2 Answers
2






active

oldest

votes


















1












$begingroup$

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.






share|improve this answer









$endgroup$













  • $begingroup$
    I see. Thank you
    $endgroup$
    – blueWings
    yesterday










  • $begingroup$
    @blueWings You’re welcome. So, have you tried changing the threshold?
    $endgroup$
    – pythinker
    yesterday










  • $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
    yesterday



















0












$begingroup$

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






share|improve this answer









$endgroup$













  • $begingroup$
    I haven't. Thank you for useful insights.
    $endgroup$
    – blueWings
    5 hours ago












Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "557"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






blueWings is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48761%2flogistic-regression-highly-sensitive-model%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1












$begingroup$

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.






share|improve this answer









$endgroup$













  • $begingroup$
    I see. Thank you
    $endgroup$
    – blueWings
    yesterday










  • $begingroup$
    @blueWings You’re welcome. So, have you tried changing the threshold?
    $endgroup$
    – pythinker
    yesterday










  • $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
    yesterday
















1












$begingroup$

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.






share|improve this answer









$endgroup$













  • $begingroup$
    I see. Thank you
    $endgroup$
    – blueWings
    yesterday










  • $begingroup$
    @blueWings You’re welcome. So, have you tried changing the threshold?
    $endgroup$
    – pythinker
    yesterday










  • $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
    yesterday














1












1








1





$begingroup$

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.






share|improve this answer









$endgroup$



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.







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









pythinkerpythinker

5031211




5031211












  • $begingroup$
    I see. Thank you
    $endgroup$
    – blueWings
    yesterday










  • $begingroup$
    @blueWings You’re welcome. So, have you tried changing the threshold?
    $endgroup$
    – pythinker
    yesterday










  • $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
    yesterday


















  • $begingroup$
    I see. Thank you
    $endgroup$
    – blueWings
    yesterday










  • $begingroup$
    @blueWings You’re welcome. So, have you tried changing the threshold?
    $endgroup$
    – pythinker
    yesterday










  • $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
    yesterday
















$begingroup$
I see. Thank you
$endgroup$
– blueWings
yesterday




$begingroup$
I see. Thank you
$endgroup$
– blueWings
yesterday












$begingroup$
@blueWings You’re welcome. So, have you tried changing the threshold?
$endgroup$
– pythinker
yesterday




$begingroup$
@blueWings You’re welcome. So, have you tried changing the threshold?
$endgroup$
– pythinker
yesterday












$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
yesterday




$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
yesterday











0












$begingroup$

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






share|improve this answer









$endgroup$













  • $begingroup$
    I haven't. Thank you for useful insights.
    $endgroup$
    – blueWings
    5 hours ago
















0












$begingroup$

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






share|improve this answer









$endgroup$













  • $begingroup$
    I haven't. Thank you for useful insights.
    $endgroup$
    – blueWings
    5 hours ago














0












0








0





$begingroup$

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






share|improve this answer









$endgroup$



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







share|improve this answer












share|improve this answer



share|improve this answer










answered 11 hours ago









FrancoSwissFrancoSwiss

10115




10115












  • $begingroup$
    I haven't. Thank you for useful insights.
    $endgroup$
    – blueWings
    5 hours ago


















  • $begingroup$
    I haven't. Thank you for useful insights.
    $endgroup$
    – blueWings
    5 hours ago
















$begingroup$
I haven't. Thank you for useful insights.
$endgroup$
– blueWings
5 hours ago




$begingroup$
I haven't. Thank you for useful insights.
$endgroup$
– blueWings
5 hours ago










blueWings is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















blueWings is a new contributor. Be nice, and check out our Code of Conduct.













blueWings is a new contributor. Be nice, and check out our Code of Conduct.












blueWings is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Data Science Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48761%2flogistic-regression-highly-sensitive-model%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to label and detect the document text images

Vallis Paradisi

Tabula Rosettana