Repository navigation
Expand file tree
/
Copy pathtutorials.html
More file actions
658 lines (640 loc) · 31.8 KB
/
Copy pathtutorials.html
File metadata and controls
658 lines (640 loc) · 31.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PyHealth Tutorials</title>
<meta name="description" content="Nine Colab notebooks that teach PyHealth 2.1, from a 10-minute quickstart study to calibration, interpretability, clinical text and contributing.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=Source+Serif+4:opsz,wght@8..60,500;8..60,600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/styles.css">
<style>
/* ── Hero ── */
.ph-hero {
background: linear-gradient(140deg, #1c2b3a 0%, #28425e 60%, #1e3348 100%);
border-radius: 16px;
padding: 3rem 2.4rem 2.8rem;
color: white;
position: relative;
overflow: hidden;
border: 1px solid rgba(255,255,255,0.07);
box-shadow: 0 20px 48px rgba(22,33,31,0.18);
animation: rise 420ms ease;
}
.ph-hero::before {
content: "";
position: absolute;
top: -80px; right: -80px;
width: 340px; height: 340px;
border-radius: 50%;
background: radial-gradient(circle, rgba(201,95,38,0.22) 0%, transparent 70%);
pointer-events: none;
}
.ph-hero::after {
content: "";
position: absolute;
bottom: -100px; left: -60px;
width: 280px; height: 280px;
border-radius: 50%;
background: radial-gradient(circle, rgba(90,160,230,0.1) 0%, transparent 70%);
pointer-events: none;
}
.ph-eyebrow {
font-size: 0.8rem;
font-weight: 600;
letter-spacing: 0.1em;
text-transform: uppercase;
color: rgba(201,95,38,0.9);
margin: 0 0 0.6rem;
}
.ph-hero h1 {
color: white;
font-size: clamp(2rem, 4.5vw, 3.2rem);
margin: 0 0 0.5rem;
letter-spacing: -0.01em;
}
.ph-tagline {
color: rgba(255,255,255,0.72);
font-size: 1.05rem;
line-height: 1.55;
max-width: 620px;
margin: 0 0 1.8rem;
}
.ph-cta-row {
display: flex;
gap: 0.7rem;
flex-wrap: wrap;
position: relative;
z-index: 1;
}
.ph-btn {
display: inline-flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
border-radius: 10px;
padding: 0.64rem 1.15rem;
font-size: 0.95rem;
font-weight: 500;
font-family: "IBM Plex Sans", sans-serif;
transition: filter 0.15s, transform 0.1s;
}
.ph-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.ph-btn.primary {
background: var(--accent);
color: white;
border: 1px solid rgba(255,255,255,0.1);
box-shadow: 0 4px 12px rgba(201,95,38,0.35);
}
.ph-btn.outline {
background: rgba(255,255,255,0.09);
color: rgba(255,255,255,0.9);
border: 1px solid rgba(255,255,255,0.22);
backdrop-filter: blur(6px);
}
/* ── Back nav ── */
.back-link {
display: inline-flex;
align-items: center;
gap: 0.35rem;
text-decoration: none;
color: var(--muted);
font-size: 0.94rem;
padding: 0.35rem 0.65rem;
border-radius: 999px;
border: 1px solid transparent;
transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.back-link:hover {
color: var(--accent);
border-color: var(--line);
background: var(--paper);
}
/* ── Section layout ── */
.research-section {
margin-top: 2.5rem;
animation: rise 500ms ease;
}
.section-h2 {
font-size: clamp(1.3rem, 2.5vw, 1.9rem);
margin: 0 0 0.35rem;
}
.section-sub {
color: var(--muted);
font-size: 1rem;
margin: 0 0 1.4rem;
line-height: 1.5;
}
/* ── Core tenets ── */
.tenets-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 0.85rem;
}
.tenet-card {
background: var(--paper);
border: 1px solid var(--line);
border-radius: 14px;
padding: 1.6rem 1.4rem;
display: flex;
flex-direction: column;
gap: 0.4rem;
transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.tenet-card:hover {
border-color: var(--accent);
box-shadow: 0 6px 20px rgba(201,95,38,0.09);
transform: translateY(-2px);
}
.tenet-icon {
font-size: 1.5rem;
line-height: 1;
margin-bottom: 0.3rem;
}
.tenet-card h3 {
font-size: 1.05rem;
margin: 0;
color: var(--ink);
}
.tenet-card p {
font-size: 0.92rem;
color: var(--muted);
margin: 0;
line-height: 1.45;
}
/* ── Terms table ── */
.terms-table-wrap {
overflow-x: auto;
border-radius: 14px;
border: 1px solid var(--line);
box-shadow: 0 4px 16px rgba(22,33,31,0.06);
}
.terms-table {
width: 100%;
border-collapse: collapse;
background: var(--paper);
font-size: 0.97rem;
}
.terms-table thead tr {
background: var(--bg);
border-bottom: 1px solid var(--line);
}
.terms-table th {
text-align: left;
font-size: 0.78rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.07em;
color: var(--muted);
padding: 0.85rem 1.4rem;
}
.terms-table td {
padding: 1rem 1.4rem;
border-bottom: 1px solid var(--line);
vertical-align: middle;
}
.terms-table tbody tr:last-child td { border-bottom: none; }
.terms-table tbody tr:hover td {
background: color-mix(in srgb, var(--accent-soft) 30%, transparent);
}
.terms-table a { color: var(--accent); text-decoration: none; }
.terms-table a:hover { text-decoration: underline; }
.term-name { font-weight: 600; color: var(--ink); }
/* ── Filter row ── */
.filter-row {
display: flex;
gap: 0.6rem;
flex-wrap: wrap;
margin-bottom: 1.2rem;
align-items: center;
}
.filter-label {
font-size: 0.85rem;
font-weight: 600;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.07em;
}
.filter-pills {
display: flex;
gap: 0.4rem;
flex-wrap: wrap;
}
.filter-pill {
border: 1px solid var(--line);
background: var(--paper);
color: var(--muted);
border-radius: 100px;
padding: 0.3rem 0.85rem;
font-size: 0.84rem;
font-weight: 500;
font-family: "IBM Plex Sans", sans-serif;
cursor: pointer;
transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.filter-pill:hover {
border-color: var(--accent);
color: var(--accent);
}
.filter-pill.active {
background: var(--accent);
border-color: var(--accent);
color: white;
}
.filter-divider {
width: 1px;
height: 18px;
background: var(--line);
margin: 0 0.2rem;
}
/* ── Paper cards ── */
.papers-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 1rem;
}
.paper-card {
background: var(--paper);
border: 1px solid var(--line);
border-radius: 14px;
padding: 1.5rem 1.5rem 1.3rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
animation: rise 500ms ease;
}
.paper-card:not(.hidden):hover {
border-color: var(--accent);
box-shadow: 0 6px 20px rgba(201,95,38,0.1);
transform: translateY(-2px);
}
.paper-card.hidden { display: none; }
.badge-row {
display: flex;
gap: 0.4rem;
flex-wrap: wrap;
margin-bottom: 0.15rem;
}
.badge {
display: inline-block;
font-size: 0.72rem;
font-weight: 600;
padding: 0.18rem 0.55rem;
border-radius: 100px;
letter-spacing: 0.03em;
}
.badge-year {
background: color-mix(in srgb, var(--accent) 12%, transparent);
color: var(--accent);
border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.badge-venue {
background: var(--bg);
color: var(--muted);
border: 1px solid var(--line);
}
.badge-review {
background: color-mix(in srgb, #a16207 10%, transparent);
color: #a16207;
border: 1px solid color-mix(in srgb, #a16207 25%, transparent);
}
.paper-title {
font-family: "Source Serif 4", Georgia, serif;
font-size: 1.05rem;
font-weight: 600;
color: var(--ink);
line-height: 1.4;
margin: 0;
}
.paper-authors {
font-size: 0.88rem;
color: var(--muted);
margin: 0;
line-height: 1.4;
}
.paper-actions {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
margin-top: auto;
padding-top: 0.5rem;
}
.paper-btn {
display: inline-flex;
align-items: center;
gap: 0.35rem;
text-decoration: none;
font-size: 0.84rem;
font-weight: 500;
font-family: "IBM Plex Sans", sans-serif;
border-radius: 8px;
padding: 0.38rem 0.75rem;
transition: filter 0.12s, transform 0.1s;
}
.paper-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.paper-btn.read {
background: var(--accent);
color: white;
border: 1px solid rgba(201,95,38,0.2);
box-shadow: 0 2px 8px rgba(201,95,38,0.25);
}
.paper-btn.details {
background: var(--bg);
color: var(--muted);
border: 1px solid var(--line);
}
.paper-btn.details:hover { color: var(--accent); border-color: var(--accent); }
.no-results {
grid-column: 1 / -1;
text-align: center;
padding: 3rem 1rem;
color: var(--muted);
font-size: 0.97rem;
}
/* ── Apply steps ── */
.apply-steps {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 1rem;
margin-top: 1rem;
}
.apply-step {
background: var(--paper);
border: 1px solid var(--line);
border-radius: 14px;
padding: 1.6rem 1.4rem;
display: flex;
flex-direction: column;
gap: 0.45rem;
transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
animation: rise 560ms ease;
}
.apply-step:hover {
border-color: var(--accent);
box-shadow: 0 6px 20px rgba(201,95,38,0.09);
transform: translateY(-2px);
}
.step-num {
font-family: "Source Serif 4", Georgia, serif;
font-size: 2.2rem;
font-weight: 600;
color: var(--accent);
line-height: 1;
margin-bottom: 0.1rem;
opacity: 0.85;
}
.apply-step h3 {
font-size: 1.05rem;
margin: 0;
color: var(--ink);
}
.apply-step p {
font-size: 0.92rem;
color: var(--muted);
margin: 0;
line-height: 1.45;
}
.apply-step-link {
display: inline-flex;
align-items: center;
gap: 0.3rem;
color: var(--accent);
font-size: 0.88rem;
font-weight: 500;
text-decoration: none;
margin-top: auto;
padding-top: 0.5rem;
}
.apply-step-link:hover { text-decoration: underline; }
/* ── Callout banner ── */
.apply-callout {
margin-top: 2rem;
background: var(--paper);
border: 1px solid var(--line);
border-radius: 14px;
padding: 1.5rem 1.6rem;
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 1rem;
}
.apply-callout p {
margin: 0.2rem 0 0;
color: var(--muted);
font-size: 0.95rem;
}
.apply-callout h3 { margin: 0; font-size: 1.1rem; }
.callout-btn {
display: inline-flex;
align-items: center;
gap: 0.45rem;
text-decoration: none;
background: var(--accent);
color: white;
border-radius: 10px;
padding: 0.6rem 1.1rem;
font-size: 0.93rem;
font-weight: 500;
font-family: "IBM Plex Sans", sans-serif;
white-space: nowrap;
transition: filter 0.15s, transform 0.1s;
}
.callout-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
@media (max-width: 600px) {
.papers-grid { grid-template-columns: 1fr; }
.apply-steps { grid-template-columns: 1fr; }
.tenets-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
.tenets-grid { grid-template-columns: 1fr; }
}
.tut-list { display: grid; gap: 0.9rem; margin-top: 1rem; }
.tut-card { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem 1.2rem; align-items: start; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.2rem; }
.tut-card:hover { border-color: var(--accent); }
.tut-num { font-family: "Source Serif 4", Georgia, serif; font-size: 1.9rem; font-weight: 600; color: var(--accent); line-height: 1; min-width: 2.2rem; }
.tut-body { min-width: 0; }
.tut-body h3 { margin: 0 0 0.35rem; font-size: 1.05rem; color: var(--ink); }
.tut-body ul { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.tut-meta { margin: 0.45rem 0 0; font-size: 0.82rem; color: var(--muted); }
.tut-guide { display: block; margin-top: 0.8rem; max-width: 460px; text-decoration: none; }
.tut-guide img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; background: #F5F8FA; }
.tut-guide span { display: block; margin-top: 0.3rem; font-size: 0.78rem; color: var(--muted); }
.tut-guide:hover img { border-color: var(--accent); }
.tut-btn { white-space: nowrap; align-self: center; }
.tut-note { color: var(--muted); font-size: 0.9rem; max-width: 720px; }
.tut-note code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 0.05rem 0.35rem; font-size: 0.85rem; }
@media (max-width: 640px) { .tut-card { grid-template-columns: auto 1fr; } .tut-btn { grid-column: 1 / -1; justify-self: start; } }
</style>
<link rel="icon" href="/favicon.ico" sizes="any">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="icon" href="/favicon-32x32.png" type="image/png" sizes="32x32">
<link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="180x180">
</head>
<body>
<header class="site-header">
<div class="site-wrap header-inner">
<nav class="nav" aria-label="Main navigation">
<a href="index.html" class="back-link">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>
PyHealth
</a>
</nav>
<span style="color: var(--muted); font-size: 0.88rem; font-weight: 500;">Tutorials</span>
</div>
</header>
<main class="site-wrap" style="padding: 2.2rem 0 3.5rem;">
<section class="ph-hero">
<p class="ph-eyebrow">PyHealth Tutorials</p>
<h1>Learn PyHealth in Colab</h1>
<p class="ph-tagline">Nine hands-on notebooks for PyHealth 2.1, from your first clinical prediction model to calibration, interpretability, clinical text and contributing. Every notebook runs on a free Colab runtime with synthetic or public data, so no credentials are needed.</p>
<div class="ph-cta-row">
<a href="https://colab.research.google.com/drive/1KXloapcMeYubw4dT_fPJKTY1pepH2vvl" class="ph-btn primary" target="_blank" rel="noopener">Start with the Quickstart →</a>
<a href="#whats-new" class="ph-btn outline">What's new in 2.1</a>
<a href="https://pyhealth.readthedocs.io/en/latest/" class="ph-btn outline" target="_blank" rel="noopener">Documentation</a>
</div>
</section>
<section class="research-section" id="whats-new">
<h2 class="section-h2">What's new in 2.1</h2>
<p class="tut-note">Already using PyHealth? Three short notebooks, about 10 minutes each, show every 2.1 change on runnable examples: the pitfall it fixes, the new API, and how to read the output. See also the <a href="https://github.com/sunlabuiuc/PyHealth/releases/tag/v2.1.0" target="_blank" rel="noopener">release notes</a>.</p>
<div class="tut-list">
<article class="tut-card">
<div class="tut-num">1</div>
<div class="tut-body">
<h3>Splits you can trust, runs you can repeat</h3>
<ul><li><code>set_task(task, split=PatientSplit(...))</code>: why fitting vocabularies on all patients leaks test information, measured on real numbers</li><li>Four-way splits with a calibration set</li><li>Reproducible training from <code>torch.manual_seed</code> alone, and seeded loaders</li><li>The one action item for 2.0 users: rebuild caches made with more than 10 workers</li></ul>
<p class="tut-meta">about 10 minutes on a free Colab CPU runtime · Before this: the Quickstart, or any PyHealth 2.0 experience</p>
<a class="tut-guide" href="images/tutorials/21-1-splits-reproducibility.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/21-1-splits-reproducibility.svg" alt="Visual guide: Split patients before fitting the vocabulary" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1yqgMaVuGWw6IGjDi6L_S7MHp087A2fWg" target="_blank" rel="noopener">Open in Colab →</a>
</article>
<article class="tut-card">
<div class="tut-num">2</div>
<div class="tut-body">
<h3>Calibration, confidence intervals and imbalanced outcomes</h3>
<ul><li><code>set_pos_weight</code>, including <code>"balanced"</code>, and what weighting does to calibration</li><li>Brier score, observed/expected ratio, calibration slope and intercept</li><li>Patient-level <code>bootstrap_ci</code> and <code>paired_bootstrap_diff</code>: is model A really better than B?</li></ul>
<p class="tut-meta">about 10 minutes on a free Colab CPU runtime · Before this: the Quickstart, or any PyHealth 2.0 experience</p>
<a class="tut-guide" href="images/tutorials/21-2-calibration-intervals.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/21-2-calibration-intervals.svg" alt="Visual guide: Good rankings need calibrated probabilities" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1uzdKvu8Gf5snQI5uURh9iBJojGFduc3F" target="_blank" rel="noopener">Open in Colab →</a>
</article>
<article class="tut-card">
<div class="tut-num">3</div>
<div class="tut-body">
<h3>XGBoost with exact explanations, medical-code translation and new processors</h3>
<ul><li><code>XGBoostModel</code>: a strong baseline in four lines that works with <code>Trainer.evaluate</code></li><li>Exact TreeSHAP explanations with <code>mean_abs_shap</code> and <code>explain</code></li><li>ICD-9 ↔ ICD-10 translation and CCSR groupings in <code>CrossMap</code>, with unmapped codes reported</li><li>The compact <code>nested_multihot</code> encoding and <code>TensorProcessor.size()</code></li></ul>
<p class="tut-meta">about 10 minutes on a free Colab CPU runtime · Before this: the Quickstart, or any PyHealth 2.0 experience</p>
<a class="tut-guide" href="images/tutorials/21-3-xgboost-mapping.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/21-3-xgboost-mapping.svg" alt="Visual guide: Strong baselines and explicit code representations" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1rx6J10qVlXbLphG-sn3yhddWXT21uZXK" target="_blank" rel="noopener">Open in Colab →</a>
</article>
</div>
</section>
<section class="research-section">
<h2 class="section-h2">The full series</h2>
<p class="tut-note">Open a notebook and choose <strong>Runtime > Run all</strong>. The first cell installs <code>pyhealth==2.1.0</code>. Each tutorial lists what it assumes, so you can also jump straight to the topic you need. Tested end to end on Colab with PyHealth 2.1.0.</p>
<div class="tut-list">
<article class="tut-card">
<div class="tut-num">00</div>
<div class="tut-body">
<h3>Quickstart: a complete clinical prediction study</h3>
<ul><li>A full study in one notebook: predict in-hospital death from an admission's diagnosis, procedure and drug codes, with a leakage-free patient split</li><li>See the data and the cohort: a patient's record, the most common codes, and a Table 1 of survivors and deaths with p-values</li><li>Compare logistic regression, an RNN and XGBoost: ROC-AUC and PR-AUC with 95% confidence intervals, calibration, and a top-10% risk review</li><li>Explain and check the best model with SHAP and subgroup results, then export every table and figure, plus a drafted results paragraph, to use as a template</li></ul>
<p class="tut-meta">about 10 minutes on a free Colab T4 GPU, the runtime it opens with (about 15 on a CPU) · Before this: nothing. This is the place to start</p>
<a class="tut-guide" href="images/tutorials/00-quickstart.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/00-quickstart.svg" alt="Visual guide: A complete clinical prediction study" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1KXloapcMeYubw4dT_fPJKTY1pepH2vvl" target="_blank" rel="noopener">Open in Colab →</a>
</article>
<article class="tut-card">
<div class="tut-num">01</div>
<div class="tut-body">
<h3>Datasets: patients, events and your own data</h3>
<ul><li>The difference between a dataset and a task, and why PyHealth keeps them apart</li><li>How to explore patients and their events, filter by type, time or admission</li><li>What the YAML config does, and how caching works</li><li>How to load your own CSV files with a short config, no new class needed</li></ul>
<p class="tut-meta">about 20 minutes on a free Colab CPU runtime · Before this: Tutorial 00 (Quickstart) is helpful but not required</p>
<a class="tut-guide" href="images/tutorials/01-datasets.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/01-datasets.svg" alt="Visual guide: One dataset, many clinical questions" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1azBqFS_vrJxoYMxP4M_dAIDcrU92uNDv" target="_blank" rel="noopener">Open in Colab →</a>
</article>
<article class="tut-card">
<div class="tut-num">02</div>
<div class="tut-body">
<h3>Tasks and processors: from patients to model-ready samples</h3>
<ul><li>What a task is: a function from one patient to a list of samples</li><li>How input and output schemas pick a processor for each field</li><li>What each common processor produces (sequence, nested sequence, multi-hot, tensor, labels)</li><li>How to write your own task, filter patients early, and use it with any model</li></ul>
<p class="tut-meta">about 25 minutes on a free Colab CPU runtime · Before this: Tutorial 01 (Datasets)</p>
<a class="tut-guide" href="images/tutorials/02-tasks-processors.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/02-tasks-processors.svg" alt="Visual guide: Turn a clinical question into tensors" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1ndi6HGnC_l_1s23LUmzcICPgfc-cJn2N" target="_blank" rel="noopener">Open in Colab →</a>
</article>
<article class="tut-card">
<div class="tut-num">03</div>
<div class="tut-body">
<h3>Training and evaluating models properly</h3>
<ul><li>How to split so that nothing about the test patients leaks into training</li><li>How to control training: epochs, early stopping, learning rate, checkpoints</li><li>How to handle a rare outcome with a positive-class weight, and what it costs</li><li>How to report discrimination and calibration with patient-level confidence intervals</li></ul>
<p class="tut-meta">about 25 minutes on a free Colab CPU runtime · Before this: Tutorials 00 and 02</p>
<a class="tut-guide" href="images/tutorials/03-training-evaluation.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/03-training-evaluation.svg" alt="Visual guide: Train, select, and report on separate patients" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1dCOzL7JVmxgXqNw4wLny3L3z_L0ivyXi" target="_blank" rel="noopener">Open in Colab →</a>
</article>
<article class="tut-card">
<div class="tut-num">04</div>
<div class="tut-body">
<h3>Choosing a model: from logistic regression to XGBoost</h3>
<ul><li>What the main PyHealth models assume about the data, and when to pick each</li><li>How to compare several models fairly on the same patients</li><li>How to add a gradient-boosted tree baseline (XGBoost) to a PyHealth benchmark</li></ul>
<p class="tut-meta">about 12 minutes on a T4 GPU, the runtime it opens with (about 15 on a CPU, without the three sequence models) · Before this: Tutorial 03</p>
<a class="tut-guide" href="images/tutorials/04-choosing-model.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/04-choosing-model.svg" alt="Visual guide: Compare model assumptions on the same task" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1hHJ1Ll6lQIq95EnRzn3jC9V2XeP-0lU2" target="_blank" rel="noopener">Open in Colab →</a>
</article>
<article class="tut-card">
<div class="tut-num">05</div>
<div class="tut-body">
<h3>Interpreting predictions</h3>
<ul><li>Which inputs drive a model overall (global importance) and for one patient (local explanation)</li><li>Exact TreeSHAP for XGBoost, and Integrated Gradients for neural models</li><li>How to check whether an explanation is faithful to the model, not just plausible</li></ul>
<p class="tut-meta">about 20 minutes on a free Colab CPU runtime · Before this: Tutorial 04 (we reuse its heart-failure task)</p>
<a class="tut-guide" href="images/tutorials/05-interpreting-predictions.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/05-interpreting-predictions.svg" alt="Visual guide: Explain a prediction, then check the explanation" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1sS0kvQ51NUue_f4p1mFlsKV6pvhdc_AD" target="_blank" rel="noopener">Open in Colab →</a>
</article>
<article class="tut-card">
<div class="tut-num">06</div>
<div class="tut-body">
<h3>Medical codes: lookups, mappings and groupers</h3>
<ul><li>What the common code systems are (ICD-9, ICD-10, CCS, ATC, NDC) and how they relate</li><li>How to look up a code's name, parents and children</li><li>How to translate between ICD-9 and ICD-10 and group codes into broader categories</li><li>How to use a grouping inside a task to shrink the vocabulary a model must learn</li></ul>
<p class="tut-meta">about 15 minutes on a free Colab CPU runtime · Before this: Tutorial 02 (processors and vocabularies)</p>
<a class="tut-guide" href="images/tutorials/06-medical-codes.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/06-medical-codes.svg" alt="Visual guide: Look up, translate, and group medical codes" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1P_yEVCeza0SRtvI800fOdfLlhEwg1Wsh" target="_blank" rel="noopener">Open in Colab →</a>
</article>
<article class="tut-card">
<div class="tut-num">07</div>
<div class="tut-body">
<h3>Clinical text: classification and medical coding</h3>
<ul><li>How to fine-tune a Hugging Face language model on clinical notes with PyHealth</li><li>How to read a label distribution before modelling, and what a model's correct answers look like</li><li>Multiclass text classification: which specialty wrote this report?</li><li>Multilabel medical coding: which ICD codes does this note support?</li><li>Why a simple TF-IDF baseline belongs next to every language model</li></ul>
<p class="tut-meta">about 15 minutes on a T4 GPU, the runtime it opens with (about 25 on a CPU, with a smaller model) · Before this: Tutorials 00 and 02</p>
<a class="tut-guide" href="images/tutorials/07-clinical-text.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/07-clinical-text.svg" alt="Visual guide: One text input, two kinds of prediction" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1Q9TrbXxitZ8Cr1R9G2XyWTolooQYq-lg" target="_blank" rel="noopener">Open in Colab →</a>
</article>
<article class="tut-card">
<div class="tut-num">08</div>
<div class="tut-body">
<h3>Contributing a dataset or task to PyHealth</h3>
<ul><li>Whether your idea is a dataset, a task, or both</li><li>How a dataset class is built: config, default tables, per-table preprocessing, a default task</li><li>How to handle data that is not a table (files on disk)</li><li>How to test it with tiny synthetic data, and what a PR needs to pass review</li></ul>
<p class="tut-meta">about 25 minutes on a free Colab CPU runtime · Before this: Tutorials 01 and 02</p>
<a class="tut-guide" href="images/tutorials/08-contributing.svg" target="_blank" rel="noopener" title="Open the visual guide full size"><img src="images/tutorials/08-contributing.svg" alt="Visual guide: Put each contribution in the right layer" loading="lazy" width="1440" height="940"><span>Visual guide · click to enlarge</span></a>
</div>
<a class="ph-btn primary tut-btn" href="https://colab.research.google.com/drive/1tuiooZgK-rR50NdCG9Ylq5HNgqSUBwvE" target="_blank" rel="noopener">Open in Colab →</a>
</article>
</div>
</section>
</main>
<footer class="site-footer">
<div class="site-wrap" style="display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:0.5rem;">
<span>Copyright <span id="year"></span> PyHealth Team</span>
<a href="index.html" style="color:var(--accent); text-decoration:none; font-size:0.9rem;">← Back to PyHealth</a>
</div>
</footer>
<script>document.getElementById('year').textContent = new Date().getFullYear();</script>
</body>
</html>