Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Fractalis
fractalis
Commits
f6917758
Commit
f6917758
authored
Oct 17, 2018
by
Sascha Herzinger
Browse files
#34 Add "observed" variable option to Survival Analysis
parent
8570c3ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
fractalis/analytics/tasks/survival/main.py
View file @
f6917758
...
...
@@ -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
()
...
...
tests/unit/analytics/survival/test_main.py
View file @
f6917758
...
...
@@ -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
],
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment