Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
zzachw committed Nov 10, 2022
1 parent ae10132 commit bbce71c
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 97 deletions.
4 changes: 3 additions & 1 deletion docs/api/data/pyhealth.data.Patient.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
pyhealth.data.Patient
=========================

Another basic data structure in the package. A Patient is a collection of Visit for the current patients. It contains all necessary attributes of a patient, such as ethnicity, mortality status, gender, etc. It can support various healthcare tasks.
Another basic data structure in the package. A Patient is a collection of Visit for
the current patients. It contains all necessary attributes of a patient, such as
ethnicity, mortality status, gender, etc. It can support various healthcare tasks.

.. autoclass:: pyhealth.data.Patient
:members:
Expand Down
5 changes: 4 additions & 1 deletion docs/api/data/pyhealth.data.Visit.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
pyhealth.data.Visit
=========================

Another basic data structure in the package. A Visit is a single encounter in hispital. It is a container a sequence of Event for each information aspect, such as diagnosis or medications. It also contains other necessary attributes for supporting healthcare tasks, such as the date of the visit.
Another basic data structure in the package. A Visit is a single encounter in
hospital. It is a container a sequence of Event for each information aspect,
such as diagnosis or medications. It also contains other necessary attributes
for supporting healthcare tasks, such as the date of the visit.

.. autoclass:: pyhealth.data.Visit
:members:
Expand Down
1 change: 1 addition & 0 deletions docs/api/datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Datasets
datasets/pyhealth.datasets.eICUDataset
datasets/pyhealth.datasets.OMOPDataset
datasets/pyhealth.datasets.splitter
datasets/pyhealth.datasets.utils

13 changes: 13 additions & 0 deletions docs/api/datasets/pyhealth.datasets.utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pyhealth.datasets.splitter
===================================

Several utility functions.

.. automodule:: pyhealth.datasets.utils
:members:
:undoc-members:
:show-inheritance:




4 changes: 0 additions & 4 deletions docs/api/evaluator.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/api/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ tasks, such as drug drug interaction (DDI) rate.

metrics/pyhealth.metrics.multiclass
metrics/pyhealth.metrics.multilabel
metrics/pyhealth.metrics.multiclass_avg_patient
metrics/pyhealth.metrics.binary
6 changes: 6 additions & 0 deletions docs/api/metrics/pyhealth.metrics.binary.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pyhealth.metrics.multiclass
===================================

.. currentmodule:: pyhealth.metrics.binary

.. autofunction:: binary_metrics_fn
12 changes: 2 additions & 10 deletions docs/api/metrics/pyhealth.metrics.multiclass.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,5 @@

.. currentmodule:: pyhealth.metrics.multiclass

.. autofunction:: accuracy_score
.. autofunction:: precision_score
.. autofunction:: recall_score
.. autofunction:: f1_score
.. autofunction:: roc_auc_score
.. autofunction:: average_precision_score
.. autofunction:: jaccard_score
.. autofunction:: cohen_kappa_score
.. autofunction:: r2_score
.. autofunction:: confusion_matrix
.. autofunction:: multiclass_metrics_fn

15 changes: 0 additions & 15 deletions docs/api/metrics/pyhealth.metrics.multiclass_avg_patient.rst

This file was deleted.

11 changes: 1 addition & 10 deletions docs/api/metrics/pyhealth.metrics.multilabel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,4 @@

.. currentmodule:: pyhealth.metrics.multilabel

.. autofunction:: accuracy_multilabel
.. autofunction:: precision_multilabel
.. autofunction:: recall_multilabel
.. autofunction:: f1_multilabel
.. autofunction:: roc_auc_multilabel
.. autofunction:: pr_auc_multilabel
.. autofunction:: jaccard_multilabel
.. autofunction:: cohen_kappa_multilabel
.. autofunction:: r2_score_multilabel
.. autofunction:: ddi_rate_score
.. autofunction:: multilabel_metrics_fn
4 changes: 2 additions & 2 deletions pyhealth/datasets/base_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class BaseDataset(ABC, Dataset):
code_mapping: a dictionary containing the code mapping information.
The key is a str of the source code vocabulary and the value is of
two formats:
(1) a str of the target code vocabulary;
(2) a tuple with two elements. The first element is a str of the
- a str of the target code vocabulary;
- a tuple with two elements. The first element is a str of the
target code vocabulary and the second element is a dict with
keys "source_kwargs" or "target_kwargs" and values of the
corresponding kwargs for the `CrossMap.map()` method.
Expand Down
10 changes: 6 additions & 4 deletions pyhealth/models/classicml.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@

class ClassicML:
"""Call classical ML models
Note:
The classic ML models are under development. Please use with caution!
Args:
dataset: the dataset object
tables: a list of table names to be used
target: the target table name
classifier: the classifier object from sklearn
mode: the mode of the model, can be "multilabel", "binary", "multiclass"
Examples:
>>> from pyhealth.datasets import OMOPDataset
>>> dataset = OMOPDataset(
Expand All @@ -27,7 +30,7 @@ class ClassicML:
... ) # load dataset
>>> from pyhealth.tasks import mortality_prediction_omop_fn
>>> dataset.set_task(mortality_prediction_omop_fn) # set task
>>> from pyhealth.models import ClassicML
>>> from sklearn.ensemble import RandomForestClassifier as RF
>>> model = ClassicML(
Expand All @@ -37,7 +40,6 @@ class ClassicML:
... mode="binary",
... classifier=RF(max_depth=6, max_features="sqrt", n_jobs=-1, n_estimators=50),
... )
"""

def __init__(
Expand Down
16 changes: 6 additions & 10 deletions pyhealth/tasks/drug_recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def drug_recommendation_mimic3_fn(patient: Patient):
"""Processes a single patient for the drug recommendation task.
Drug recommendation aims at recommending a set of drugs given the patient health
history (e.g., conditions and procedures).
history (e.g., conditions and procedures).
Args:
patient: a Patient object
Expand All @@ -25,7 +25,6 @@ def drug_recommendation_mimic3_fn(patient: Patient):
>>> dataset.set_task(drug_recommendation_mimic3_fn) # set task
>>> dataset.samples[0] # exampe of an training sample
[{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '19', '122', '98', '663', '58', '51']], 'procedures': [['1']], 'label': [['2', '3', '4']]}]
"""
samples = []
for i in range(len(patient)):
Expand Down Expand Up @@ -72,7 +71,7 @@ def drug_recommendation_mimic4_fn(patient: Patient):
"""Processes a single patient for the drug recommendation task.
Drug recommendation aims at recommending a set of drugs given the patient health
history (e.g., conditions and procedures).
history (e.g., conditions and procedures).
Args:
patient: a Patient object
Expand All @@ -81,7 +80,7 @@ def drug_recommendation_mimic4_fn(patient: Patient):
samples: a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key
Examples:
Examples:
>>> from pyhealth.datasets import MIMIC4Dataset
>>> mimic4_ds = MIMIC4Dataset(
... root="/srv/local/data/physionet.org/files/mimiciv/2.0/hosp",
Expand All @@ -92,7 +91,6 @@ def drug_recommendation_mimic4_fn(patient: Patient):
>>> dataset.set_task(drug_recommendation_mimic4_fn) # set task
>>> dataset.samples[0] # exampe of an training sample
[{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '19', '122', '98', '663', '58', '51']], 'procedures': [['1']], 'label': [['2', '3', '4']]}]
"""
samples = []
for i in range(len(patient)):
Expand Down Expand Up @@ -139,7 +137,7 @@ def drug_recommendation_eicu_fn(patient: Patient):
"""Processes a single patient for the drug recommendation task.
Drug recommendation aims at recommending a set of drugs given the patient health
history (e.g., conditions and procedures).
history (e.g., conditions and procedures).
Args:
patient: a Patient object
Expand All @@ -148,7 +146,7 @@ def drug_recommendation_eicu_fn(patient: Patient):
samples: a list of samples, each sample is a dict with patient_id, visit_id,
and other task-specific attributes as key
Examples:
Examples:
>>> from pyhealth.datasets import eICUDataset
>>> eicu_ds = eICUDataset(
... root="/srv/local/data/physionet.org/files/eicu-crd/2.0",
Expand All @@ -160,7 +158,6 @@ def drug_recommendation_eicu_fn(patient: Patient):
>>> dataset.set_task(drug_recommendation_eicu_fn) # set task
>>> dataset.samples[0] # exampe of an training sample
[{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '98', '663', '58', '51']], 'procedures': [['1']], 'label': [['2', '3', '4']]}]
"""
samples = []
for i in range(len(patient)):
Expand Down Expand Up @@ -205,7 +202,7 @@ def drug_recommendation_omop_fn(patient: Patient):
"""Processes a single patient for the drug recommendation task.
Drug recommendation aims at recommending a set of drugs given the patient health
history (e.g., conditions and procedures).
history (e.g., conditions and procedures).
Args:
patient: a Patient object
Expand All @@ -225,7 +222,6 @@ def drug_recommendation_omop_fn(patient: Patient):
>>> dataset.set_task(drug_recommendation_eicu_fn) # set task
>>> dataset.samples[0] # exampe of an training sample
[{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '98', '663', '58', '51'], ['98', '663', '58', '51']], 'procedures': [['1'], ['2', '3']], 'label': [['2', '3', '4'], ['0', '1', '4', '5']]}]
"""

samples = []
Expand Down
12 changes: 3 additions & 9 deletions pyhealth/tasks/length_of_stay_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def length_of_stay_prediction_mimic3_fn(patient: Patient):
Note that we define the task as a multi-class classification task.
Examples:
Examples:
>>> from pyhealth.datasets import MIMIC3Dataset
>>> mimic3_ds = MIMIC3Dataset(
... root="/srv/local/data/physionet.org/files/mimiciii/1.4",
Expand All @@ -55,7 +55,6 @@ def length_of_stay_prediction_mimic3_fn(patient: Patient):
>>> dataset.set_task(length_of_stay_prediction_mimic3_fn) # set task
>>> dataset.samples[0] # exampe of an training sample
[{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '19', '122', '98', '663', '58', '51']], 'procedures': [['1']], 'label': 4}]
"""
samples = []

Expand Down Expand Up @@ -102,7 +101,7 @@ def length_of_stay_prediction_mimic4_fn(patient: Patient):
Note that we define the task as a multi-class classification task.
Examples:
Examples:
>>> from pyhealth.datasets import MIMIC4Dataset
>>> mimic4_ds = MIMIC4Dataset(
... root="/srv/local/data/physionet.org/files/mimiciv/2.0/hosp",
Expand All @@ -113,8 +112,6 @@ def length_of_stay_prediction_mimic4_fn(patient: Patient):
>>> dataset.set_task(length_of_stay_prediction_mimic4_fn) # set task
>>> dataset.samples[0] # exampe of an training sample
[{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '19', '122', '98', '663', '58', '51']], 'procedures': [['1']], 'label': 2}]
"""
samples = []

Expand Down Expand Up @@ -161,7 +158,7 @@ def length_of_stay_prediction_eicu_fn(patient: Patient):
Note that we define the task as a multi-class classification task.
Examples:
Examples:
>>> from pyhealth.datasets import eICUDataset
>>> eicu_ds = eICUDataset(
... root="/srv/local/data/physionet.org/files/eicu-crd/2.0",
Expand All @@ -173,8 +170,6 @@ def length_of_stay_prediction_eicu_fn(patient: Patient):
>>> dataset.set_task(length_of_stay_prediction_eicu_fn) # set task
>>> dataset.samples[0] # exampe of an training sample
[{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '98', '663', '58', '51']], 'procedures': [['1']], 'label': 5}]
"""
samples = []

Expand Down Expand Up @@ -232,7 +227,6 @@ def length_of_stay_prediction_omop_fn(patient: Patient):
>>> dataset.set_task(length_of_stay_prediction_eicu_fn) # set task
>>> dataset.samples[0] # exampe of an training sample
[{'visit_id': '130744', 'patient_id': '103', 'conditions': [['42', '109', '98', '663', '58', '51']], 'procedures': [['1']], 'label': 7}]
"""
samples = []

Expand Down
Loading

0 comments on commit bbce71c

Please sign in to comment.