from _api_doc_utils import *ExponentialPH
Parametric proportional hazards with constant baseline hazard
1 Where it fits
Group: Survival / event-time models
ExponentialPH is the smallest fully parametric proportional-hazards model in the module. It assumes
\[ h_i(t \mid x_i) = \lambda_0 \exp(x_i'eta), \]
so the baseline hazard is constant over time. Because the full hazard is identified, the class can expose the whole prediction stack: log hazard, hazard, cumulative hazard, and survival.
2 Python API
Constructor: cm.ExponentialPH
Use fit(x, time, event). The layered prediction surface is predict_lin(x) for log hazard, predict_hazard(x), predict_cumulative_hazard(x, time), and predict_survival(x, time). The default predict(x, time) returns survival probabilities.
print(inspect.signature(cm.ExponentialPH))cls = cm.ExponentialPH
display(HTML(html_table(["Public method"], public_methods(cls))))3 Minimal example
rng=np.random.default_rng(31)
x=rng.normal(size=(250,2)); rate=0.04*np.exp(x@np.array([0.5,-0.3])); t_event=rng.exponential(1.0/rate); c=rng.exponential(30,size=250)
time=np.minimum(t_event,c); event=(t_event<=c).astype(float)
model=cm.ExponentialPH(); model.fit(x,time,event)
print(model.predict_lin(x[:3]))
print(model.predict_hazard(x[:3]))
print(model.predict_cumulative_hazard(x[:3], time[:3]))
print(model.predict(x[:3], time[:3]))4 summary() contract
The table below is generated by fitting the live class in this repository and then inspecting summary(). Shapes are shown because most values are plain NumPy arrays or scalars.
rng=np.random.default_rng(131); x=rng.normal(size=(120,2)); rate=0.05*np.exp(x@np.array([0.4,-0.2])); te=rng.exponential(1.0/rate); c=rng.exponential(20,size=120); time=np.minimum(te,c); event=(te<=c).astype(float)
model=cm.ExponentialPH(); model.fit(x,time,event)
summary = model.summary()
display(HTML(html_table(["summary() key", "shape"], summary_shape_rows(summary))))