繪製並比較生存曲線
回到心臟科診間,你想向研究主管呈現一些視覺化圖表,凸顯病患生存時間的差異。你將把有與沒有心包膜積液的病患生存曲線並排繪出。
KaplanMeierFitter 物件 kmf 已經建立。有與沒有心包膜積液的病患資料已載入,分別儲存在 has_pericardial_effusion 與 none_pericardial_effusion 的 DataFrame 中。
KaplanMeierFitter 類別已為你匯入。此外,pandas 套件已以 pd 載入,matplotlib.pyplot 模組已以 plt 載入。
本練習屬於課程
Python 的存活分析
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Fit kmf to patients with pericardial effusion
____.____(____, ____, label='has_pericardial_effusion')
# Create a plot of the survival function
surv_plot = kmf.____()