Skip to content

ENH: predicted probabilities and classification, with population prevalence #9684

Open

Description

@josef-pkt

some semi-random thought, largely following from #9680 (comment)

  • (medical) diagnostic tests are often reduced to a binary or ordinal decision, even if the underlying measure is continuous or has many points in support. (*)
  • In binary setting, ROC and AUC are used to evaluate performance of a diagnostic or predictive model. e.g. sklearn to compute ROC and AUC from predicted probabilities of logistic regression
  • prevalence and unbalanced samples: categories that have only a small number of observations will have no or few cases that would be correctly classified. The question is whether the sample is representative or if population prevalence differs from sample prevalence.
  • positive predicted value, PPV, and negative predicted value, NPV, can use population prevalence that differs from sample prevalence

I ran into this article but did not understand the background
Waegeman, Willem, Bernard De Baets, and Luc Boullart. 2008. “ROC Analysis in Ordinal Regression Learning.” Pattern Recognition Letters 29 (1): 1–9. https://doi.org/10.1016/j.patrec.2007.07.019.

The simpler case is binary decision:
For example https://www.kaggle.com/code/shubhamlipare/logistic-regression-with-auc-roc-curve
which has roc and auc using sklearn.

Maybe it's not even good to convert predicted probabilities to classification
https://www.fharrell.com/post/classification/
https://www.fharrell.com/post/class-damage/
https://library.virginia.edu/data/articles/roc-curves-and-auc-for-models-used-for-binary-classification
and their references like (not read)
Goorbergh, Ruben van den, Maarten van Smeden, Dirk Timmerman, and Ben Van Calster. 2022. “The Harm of Class Imbalance Corrections for Risk Prediction Models: Illustration and Simulation Using Logistic Regression.” Journal of the American Medical Informatics Association 29 (9): 1525–34. https://doi.org/10.1093/jamia/ocac093.

What to we do if we eventually have to make a decision, e.g. recommend a treatment or a follow-up test.

I never really looked into classification. The only part we have, are the confusion tables for binary and multinomial/ordinal. (And there I got stuck with cases where some categories were never predicted by max(probs).)

ROC computation in sklearn allow for weights.
Similarly we can use weights in prediction (get_prediction for averages) to have the population distribution in prediction differ from the sample population.

Does it help to compute confusion tables and similar for fictitious population, similarly to changed prevalence in PPV and NPV,

Threshold selection at the final stage:
Thresholds would depend on cost of the different correct or false decisions in the target population.
Waegeman et al. have different "cost functions" for ordinal classification, e.g. Youden index.
Some of those might make good eval_measures.

Aside: With threshold selection in a separate step, only the ranking of predictions is important, thresholds can shift the magnitudes or absolute values, i.e. we drop the interpretation as probabilities.

Does it make sense to make thresholds depend on some explanatory variables, discrimination, reverse discrimination, preferential treatment?
(The explanatory could be also in the estimation, but here it would be a decision problem independently of the estimation.)

aside: I still don't have answers to the machine learning class imbalance questions. That's still to figure out.
#2701 #505 (comment)

Activity

  1. ChenyangLi4288 commented on Nov 16, 2026

    @ChenyangLi4288
    Contributor

    Hi @josef-pkt, I'd like to pick up the narrow part of this, a diagnostic-test summary for a binary 2×2 table (or pred_table at a threshold).

    It would include sensitivity, specificity, LR+/LR−, the Youden index, and PPV/NPV at either the sample prevalence or a user-supplied population prevalence, each with confidence intervals: proportion_confint for sensitivity and specificity, the log method for the likelihood ratios (Simel et al. 1991), and logit intervals for prevalence-adjusted PPV/NPV (Mercaldo, Lau & Zhou 2007). It would return a results object with summary(), somewhere like statsmodels.stats.

    After that, AUC with a DeLong CI and weights could be a follow-up. Does this scope sound reasonable to you? It's just some random thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions