Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ reference includes the ECE definition and formula used by these helpers.
metrics/pyhealth.metrics.anomaly_detection
metrics/pyhealth.metrics.value_set
metrics/pyhealth.metrics.motionage
metrics/pyhealth.metrics.event_alarm
33 changes: 33 additions & 0 deletions docs/api/metrics/pyhealth.metrics.event_alarm.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pyhealth.metrics.event_alarm
============================

Event-level metrics of an alarm policy for early event prediction (Hyland et
al., 2020; Section 4.1 of Yeche et al., 2024): a threshold on the risk score
with silencing, alarm precision, event recall at a given alarm precision, the
distance of the first alarm to the event, and the area under the alarm
precision / event recall curve. They complement the time-step ROC-AUC and
PR-AUC, which do not tell how early or how often a system raises alarms.

.. code-block:: python

from pyhealth.metrics import event_alarm_metrics

scores = event_alarm_metrics(
scores=risk_per_stay, # list of [steps] arrays
times=hours_per_stay,
time_to_event=tte_per_stay, # from DecompensationMIMIC3(label_mode="survival")
event=event_per_stay,
horizon=24,
silence=1.0,
)
# {'alarm_event_auprc': ..., 'event_recall@60': ..., 'first_alarm_distance@60': ...}

.. currentmodule:: pyhealth.metrics.event_alarm

.. autofunction:: alarm_policy

.. autofunction:: alarm_curve

.. autofunction:: alarm_event_auprc

.. autofunction:: event_alarm_metrics
1 change: 1 addition & 0 deletions docs/api/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ API Reference
models/pyhealth.models.camchex
models/pyhealth.models.UNet
models/pyhealth.models.RNN
models/pyhealth.models.DynamicSurvivalRNN
models/pyhealth.models.GNN
models/pyhealth.models.Transformer
models/pyhealth.models.StepWiseTransformer
Expand Down
18 changes: 18 additions & 0 deletions docs/api/models/pyhealth.models.DynamicSurvivalRNN.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pyhealth.models.DynamicSurvivalRNN
==================================

Dynamic survival analysis for early event prediction (Yeche et al., CHIL 2024):
an :class:`~pyhealth.models.RNN_V2` encoder with a hazard head, a survival loss
truncated to the prediction horizon, and hazard-bias initialization.

.. autoclass:: pyhealth.models.DynamicSurvivalRNN
:members:
:undoc-members:
:show-inheritance:

.. autofunction:: pyhealth.models.dynamic_survival_rnn.survival_loss

.. autofunction:: pyhealth.models.dynamic_survival_rnn.hazards_to_risk

.. automodule:: pyhealth.models.dynamic_survival
:members:
1 change: 1 addition & 0 deletions docs/api/tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,4 @@ Available Tasks
Vasopressor Onset (MIMIC-III) <tasks/pyhealth.tasks.VasopressorOnsetMIMIC3>
Vasopressor Onset (MIMIC-IV) <tasks/pyhealth.tasks.VasopressorOnsetMIMIC4>
Temporal Clinical Outcome Prediction (MIMIC-IV) <tasks/pyhealth.tasks.temporal_outcome_prediction_mimic4>
Decompensation (MIMIC-III) <tasks/pyhealth.tasks.decompensation_mimic3>
7 changes: 7 additions & 0 deletions docs/api/tasks/pyhealth.tasks.decompensation_mimic3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pyhealth.tasks.decompensation_mimic3
====================================

.. autoclass:: pyhealth.tasks.decompensation_mimic3.DecompensationMIMIC3
:members:
:undoc-members:
:show-inheritance:
Loading