Gitlab is now using https://gitlab.lcsb.uni.lu as it's primary address. Please update your bookmarks. FAQ.

Commit f6917758 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

#34 Add "observed" variable option to Survival Analysis

parent 8570c3ce
......@@ -58,7 +58,7 @@ class SurvivalTask(AnalyticTask):
if event_observed:
# find observation boolean value for every duration
E = event_observed[0].merge(sub_df, how='right', on='id')
E = [bool(x) and not np.isnan(x) for x in E['value']]
E = [not x for x in pd.isnull(E['value_x'])]
assert len(E) == len(T)
if estimator == 'NelsonAalen':
fitter = NelsonAalenFitter()
......
......@@ -37,8 +37,11 @@ class TestSurvivalTask:
duration.columns.values[2] = 'value'
event_observed = df[['id', 'E']].copy()
event_observed.insert(1, 'feature', 'was_observed')
event_observed.columns.values[2] = 'value'
event_observed = event_observed[event_observed['value'] == 1]
categories = df[['id', 'group']].copy()
categories.insert(1, 'feature', 'group')
categories.columns.values[2] = 'value'
results = self.task.main(durations=[duration],
categories=[categories],
event_observed=[event_observed],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment