Survivalanalyse in Python
Shae Wang
Senior Data Scientist
Geeft een plot van de coëfficiënten met hun 95%-betrouwbaarheidsintervallen.
aft.plot()
plt.show()
Voorbeeldplot:

Geeft een plot die de baseline-overlevingscurve vergelijkt met variaties in covariaten.
aft.plot_partial_effects_on_outcome(covariates, values)
plt.show()

.plot_partial_effects_on_outcome()
covariates (string of lijst): covaria(a)t(en) uit de originele dataset die we willen variëren.values (1D of 2D iterable): gewenste waarden voor de covariaat.
Baseline-overlevingscurve: voorspelde curve bij alle gemiddelde waarden in de originele dataset.
aft.plot_partial_effects_on_outcome(
covariates='var',
values=[0, 3, 6, 9, 12, 15]
)
plt.show()

aft.plot_partial_effects_on_outcome(
covariates='a',
values=[0, 3, 6]
)
aft.plot_partial_effects_on_outcome(
covariates='a',
values=np.arange(10)
)
aft.plot_partial_effects_on_outcome(
covariates=['a','b'],
values=[[1,2],[1,3],[2,3]]
)
DataFrame-voorbeeld: mortgage_df
| id | house | principal | interest | property_tax | credit score | duration | paid_off |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 1275 | 0.035 | 0.019 | 780 | 25 | 0 |
| 2 | 0 | 756 | 0.028 | 0.020 | 695 | 17 | 1 |
| 3 | 0 | 968 | 0.029 | 0.017 | 810 | 5 | 0 |
| ... | ... | ... | ... | ... | ... | ... | ... |
| 1000 | 1 | 1505 | 0.041 | 0.023 | 750 | 30 | 1 |
aft.plot_partial_effects_on_outcome(
covariates='credit score',
values=np.arange(700, 860, 30)
)
plt.show()


Voorspel overlevingsfuncties per individu op basis van covariaatwaarden.
.predict_survival_function()
Argumenten:
X (np array of DataFrame): covariaten. Bij een DataFrame mogen kolommen in willekeurige volgorde staan.Voorspel mediane overlevingsduur per individu op basis van covariaatwaarden.
.predict_median()
Argumenten:
df (np array of DataFrame): covariaten. Bij een DataFrame mogen kolommen in willekeurige volgorde staan.Voorspel overlevingsfunctie of mediane duur, voorwaardelijk na de huidige duur.
.predict_survival_function(X, conditional_after).predict_median(df, conditional_after)Voorbeeld:
aft.predict_median(new_subject)
4.0
aft.predict_median(new_subject, conditional_after=[2])
2.0
Survivalanalyse in Python