# Logistic regression metric

I am interested to understand in which scenarios person should use sensitivity, specificity, and when should person opt for precision recall.

On a high level I understand for a balanced data set we should use precision, recall and if dataset is imbalanced we should use sensitivity and specificity. but I am not sure why they say it. If you people have different perspective, pls throw some light on how to perceive these.

None of those measures are at all appropriate for logistic regression. The binary logistic regression model is a probability model. Its predictive performance should be judged by measures making full use of the model's estimated probabilities. For absolute accuracy, continuous calibration curves should be estimated (plot of actual probability vs. predicted probability with actual probability estimated in an independent test sample or using resampling). For predictive discrimination there are many measures, the simplest of which is to show a histogram of predicted probabilities with many bins, or a rug plot, and observing the width of this distribution. This article goes into several useful measures. A commonly used measure of pure predictive discrimination is the $$c$$-index or concordance probability, which happens to be the area of a receiver operating characteristic curve. This measures separation in predicted probabilities between observations with Y=0 and those with Y=1. $$c$$ is not a sensitive measure but is easy to interpret.

Sensitivity and specificity are only useful in a retrospective case-control study in which a single binary X is collected separately for those with Y=0 and those with Y=1. Sens and spec use reverse time conditioning so are usually not appropriate (they condition on the unknown to predict the known).

On a high level I understand for a balanced data set we should use precision, recall and if dataset is imbalanced we should use sensitivity and specificity. but I am not sure why they say it.

Could you please give a reference where did you get this information? For imbalanced data sets, all the measures that you have mentioned can be used, but you should avoid reporting accuracy, since it can be very misleading.

As @Frank Harrell already mentioned in his answer, the logistic regression model models probability, but it can be used to make a binary classifier, by thresholding the probability.

All the measures you mentioned (sensitivity, specificity and precision, recall) can be used for evaluation of binary classifier performance. All these measures are based on 2×2 contingency table or confusion matrix, also known as an error matrix.

To decide what measures to use, you have to think about what cells in the confusion matrix are important to you. For example in information retrieval, true negatives can be usually ignored. But in medical diagnosis usage, true negatives are also very important and that is why specificity is used instead of precision. Also note that sensitivity = recall.