[Python] How do I manually set the reference category for a Cox PH Model in python?

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm running a Cox PH Model to examine survival times among a population, and my model outputs fine, except I want to change the categories its using as the reference/baseline (i.e. right now it's using race_American Indian Alaska Native as the reference for race, which has way fewer instances than any of the others and isn't the most robust). My data is all categorical and thus all one-hot encoded (mostly True/False rather than 0/1... is that still called one-hot encoding?) except the time-to-event column. Here's my code of calling the model: cph = CoxPHFitter(penalizer=0.01) cph.fit(coxonehot_df, duration_col = 'survival_control', event_col = 'reincarcerated') cph.print_summary()

    I read through the documentationbut didn't see how to change the reference category.

    Continue reading...

Compartilhe esta Página