Skip to content
Merged
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
415 changes: 1 addition & 414 deletions examples/tutorials/series/00_quickstart.ipynb

Large diffs are not rendered by default.

618 changes: 514 additions & 104 deletions examples/tutorials/series/01_datasets.ipynb

Large diffs are not rendered by default.

493 changes: 1 addition & 492 deletions examples/tutorials/series/02_tasks_and_processors.ipynb

Large diffs are not rendered by default.

441 changes: 1 addition & 440 deletions examples/tutorials/series/03_training_and_evaluation.ipynb

Large diffs are not rendered by default.

12,417 changes: 12,306 additions & 111 deletions examples/tutorials/series/04_choosing_a_model.ipynb

Large diffs are not rendered by default.

2,638 changes: 2,541 additions & 97 deletions examples/tutorials/series/05_interpreting_predictions.ipynb

Large diffs are not rendered by default.

610 changes: 513 additions & 97 deletions examples/tutorials/series/06_medical_codes.ipynb

Large diffs are not rendered by default.

391 changes: 1 addition & 390 deletions examples/tutorials/series/07_clinical_text.ipynb

Large diffs are not rendered by default.

418 changes: 352 additions & 66 deletions examples/tutorials/series/08_contributing.ipynb

Large diffs are not rendered by default.

48 changes: 31 additions & 17 deletions examples/tutorials/series/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
# PyHealth tutorial series

Nine Colab-ready notebooks, from a first model to contributing a dataset. Each
runs on a free Colab CPU runtime with public or synthetic data, so no
credentials are needed.
Colab notebooks for PyHealth 2.1, from a first model to contributing a
dataset, plus three short notebooks on what changed in 2.1. Each one installs
`pyhealth==2.1.0` and uses public or synthetic data, so no credentials are
needed. The saved outputs come from a full run on Colab, so you can read the
results here before running anything.

## Tutorial series

| # | Notebook | Covers |
|---|---|---|
| 00 | [Quickstart](00_quickstart.ipynb) | The five steps: dataset, task, split, model, evaluation |
| 00 | [Quickstart](00_quickstart.ipynb) | A complete in-hospital mortality study: data figures, Table 1, three models with CIs and calibration, SHAP, subgroups, exported results (T4 GPU) |
| 01 | [Datasets](01_datasets.ipynb) | Patients and events, YAML configs, caching, loading your own CSVs |
| 02 | [Tasks and processors](02_tasks_and_processors.ipynb) | Writing tasks, what each processor produces |
| 03 | [Training and evaluation](03_training_and_evaluation.ipynb) | Leakage-free splits, early stopping, class imbalance, calibration, bootstrap CIs |
| 04 | [Choosing a model](04_choosing_a_model.ipynb) | Logistic regression to Transformer, plus an XGBoost baseline, on one split |
| 04 | [Choosing a model](04_choosing_a_model.ipynb) | Logistic regression, MLP, RNN, Transformer, RETAIN and XGBoost on one split (T4 GPU) |
| 05 | [Interpreting predictions](05_interpreting_predictions.ipynb) | TreeSHAP, Integrated Gradients, checking faithfulness |
| 06 | [Medical codes](06_medical_codes.ipynb) | Lookups, ICD-9/ICD-10 translation, CCS/ATC groupers, `code_mapping` |
| 07 | [Clinical text](07_clinical_text.ipynb) | Fine-tuning language models; specialty classification and ICD coding |
| 07 | [Clinical text](07_clinical_text.ipynb) | Fine-tuning language models; specialty classification and ICD coding; label distributions and baselines (T4 GPU) |
| 08 | [Contributing](08_contributing.ipynb) | Dataset classes, file-based data, tests, PR checklist |

Open one in Colab from
`https://colab.research.google.com/github/sunlabuiuc/PyHealth/blob/master/examples/tutorials/series/<notebook>.ipynb`.
Most notebooks run on a free Colab CPU runtime. Tutorials 00, 04 and 07 open on
a free T4 GPU runtime and also run on a CPU (04 and 07 with smaller settings).

## Editing
## What's new in PyHealth 2.1

The notebooks are generated from `_source/tutorials/tNN_*.py`; edit those, then
rebuild (and optionally execute) with:
| # | Notebook | Covers |
|---|---|---|
| 1 | [Splits and reproducibility](whats_new_1_splits_and_reproducibility.ipynb) | `PatientSplit`, four-way splits with a calibration set, reproducible training |
| 2 | [Calibration and confidence intervals](whats_new_2_calibration_and_intervals.ipynb) | Calibration metrics, patient-level bootstrap intervals, `set_pos_weight` |
| 3 | [XGBoost and code mapping](whats_new_3_xgboost_and_code_mapping.ipynb) | `XGBoostModel` with exact TreeSHAP, ICD-9/ICD-10 and CCSR mapping, `nested_multihot` |

```bash
python examples/tutorials/series/_source/build.py # all notebooks
python examples/tutorials/series/_source/build.py t04 --run # rebuild and execute one
```
## Opening in Colab

Open a notebook from this folder with
`https://colab.research.google.com/github/sunlabuiuc/PyHealth/blob/master/examples/tutorials/series/<notebook>.ipynb`,
or use the maintained Colab copies listed on
[pyhealth.dev](https://pyhealth.dev/tutorials.html) and in the
[documentation](https://pyhealth.readthedocs.io/en/latest/tutorials.html).

## Editing

`--run` needs `nbclient` and a Jupyter kernel with PyHealth installed; it skips
the install cell and stops at the first failing cell.
The Colab copies are the working versions; the notebooks here are exported
from them after a full run. To change a tutorial, edit it in Colab (or here),
run it end to end with **Runtime > Run all**, and commit the notebook with its
outputs.
76 changes: 0 additions & 76 deletions examples/tutorials/series/_source/build.py

This file was deleted.

123 changes: 0 additions & 123 deletions examples/tutorials/series/_source/nbkit.py

This file was deleted.

Empty file.
Loading
Loading