Model prison data with Cox PH
The DataFrame prison
contains information from 432 convicts who were released and followed up for one year after release. You have modeled their time-to-arrest and studied what factors increase or decrease their risk of re-arrest using the Weibull AFT model.
CoxPHFitter
class of lifelines
implements a Cox Proportional Hazards model for survival regression that models the baseline hazard function and hazard ratios that define hazard proportions. Let's try using CoxPHFitter
to explore the factors!
The pandas
and numpy
libraries are imported as pd
and np
, respectively. Use the console to explore the DataFrame and its column names as needed.
This exercise is part of the course
Survival Analysis in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import CoxPHFitter class
____
# Instantiate CoxPHFitter class cph
____