Phân tích sống sót bằng Python
Shae Wang
Senior Data Scientist
$$\Large{S(t) = Pr(T>t)}$$
$$\Large{S(t) = Pr(T>t)}$$

$$\Large{S(t) = Pr(T>t)}$$

$$\Large{S(t) = Pr(T>t)}$$






Gói lifelines là thư viện phân tích sống sót đầy đủ.
import lifelines
import matplotlib.pyplot as plt
.fit(durations, event_observed)
.plot_survival_function()
Tên DataFrame: mortgage_df
| id | duration | paid_off |
|---|---|---|
| 1 | 25 | 0 |
| 2 | 17 | 1 |
| 3 | 5 | 0 |
| ... | ... | ... |
| 100 | 30 | 1 |
id: mã khoản vay thế chấpduration: số năm khoản vay chưa trả hếtpaid_off: 1 nếu đã trả hết, 0 nếu chưa trả hếtimport lifelines
from matplotlib import pyplot as plt
kmf = lifelines.KaplanMeierFitter()
kmf.fit(duration=mortgage_df["duration"],
event_observed=mortgage_df["paid_off"])
kmf.plot_survival_function()
plt.show()

Phân tích sống sót bằng Python