Skip to content

Commit 8ee65c1

Browse files
authored
add files for ml session day 3 (#7)
* add files for ml session day 3 * Review day3 ml exercises
1 parent 40c0d05 commit 8ee65c1

5 files changed

Lines changed: 10871 additions & 3 deletions

day3.1_ml-application/01a_segmentation-exercise.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"import os\n",
4949
"\n",
5050
"bob.initialize(\n",
51-
" endpoint='https://kiara.sc.uni-leipzig.de/api/v1', \n",
51+
" endpoint=os.getenv('ENDPOINT_URL'),\n",
5252
" model=\"vllm-llama-4-scout-17b-16e-instruct\",\n",
5353
" system_prompt=os.getenv('SYSTEM_PROMPT_MEDICAL_AI')\n",
5454
")"

day3.1_ml-application/01b_segmentation-solution.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
{
3737
"cell_type": "code",
38-
"execution_count": 1,
38+
"execution_count": null,
3939
"id": "22e8ec8a-33bb-4f2b-a54f-1ea880ae96d4",
4040
"metadata": {},
4141
"outputs": [
@@ -63,7 +63,7 @@
6363
"import os\n",
6464
"\n",
6565
"bob.initialize(\n",
66-
" endpoint='https://kiara.sc.uni-leipzig.de/api/v1', \n",
66+
" endpoint=os.getenv('ENDPOINT_URL'),\n",
6767
" model=\"vllm-llama-4-scout-17b-16e-instruct\",\n",
6868
" system_prompt=os.getenv('SYSTEM_PROMPT_MEDICAL_AI')\n",
6969
")"
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "45ced776f13fa728",
6+
"metadata": {},
7+
"source": [
8+
"# Predicting Chronic Heart Failure"
9+
]
10+
},
11+
{
12+
"cell_type": "markdown",
13+
"id": "a90a7b680d9be480",
14+
"metadata": {},
15+
"source": [
16+
"## Clinical Use Case\n",
17+
"\n",
18+
"Patients admitted with **myocardial infarction (MI)** are at risk of\n",
19+
"developing a range of complications, including **chronic heart failure (CHF)**.\n",
20+
"\n",
21+
"Chronic heart failure is a serious condition that can significantly impair\n",
22+
"quality of life and is associated with increased morbidity and mortality.\n",
23+
"\n",
24+
"Following an acute myocardial infarction, some patients recover without\n",
25+
"long-term consequences, while others develop progressive cardiac dysfunction\n",
26+
"leading to heart failure.\n",
27+
"\n",
28+
"Early identification of patients at risk of developing chronic heart failure\n",
29+
"is challenging, even for experienced clinicians, but highly relevant for\n",
30+
"optimizing treatment and improving long-term outcomes.\n",
31+
"\n",
32+
"---\n",
33+
"\n",
34+
"**Goal of this analysis:**\n",
35+
"\n",
36+
"Build a machine learning model that predicts whether a patient will\n",
37+
"develop **chronic heart failure** during hospitalization.\n",
38+
"\n",
39+
"You can download the dataset of myocardial infarction complications from the University of Leicester here:\n",
40+
"https://figshare.le.ac.uk/ndownloader/files/23581310\n",
41+
"\n",
42+
"---\n",
43+
"\n",
44+
"## About the Dataset\n",
45+
"\n",
46+
"This dataset contains clinical information about patients admitted with\n",
47+
"myocardial infarction and was designed to evaluate real-world medical\n",
48+
"prediction problems.\n",
49+
"\n",
50+
"Variables include:\n",
51+
"\n",
52+
"- demographic data\n",
53+
"- medical history\n",
54+
"- ECG findings\n",
55+
"- laboratory values\n",
56+
"- treatment information\n",
57+
"\n",
58+
"Possible complications are stored in the target variables.\n",
59+
"\n",
60+
"In this notebook, we focus on predicting:\n",
61+
"\n",
62+
"**Chronic Heart Failure**\n",
63+
"\n",
64+
"Additional information about the dataset, including variable descriptions, can be found here:\n",
65+
"https://doi.org/10.25392/leicester.data.12045261\n",
66+
"\n",
67+
"---\n",
68+
"\n",
69+
"**Important methodological aspect**\n",
70+
"\n",
71+
"The dataset allows prediction at **different time points during the hospital stay**:\n",
72+
"\n",
73+
"1. At admission\n",
74+
"2. After 24 hours\n",
75+
"3. After 48 hours\n",
76+
"4. After 72 hours\n",
77+
"\n",
78+
"Depending on the chosen time point, **different variables are available**.\n",
79+
"\n",
80+
"For this exercise, you must **decide on one time point** and\n",
81+
"**adapt your feature selection accordingly**.\n",
82+
"\n",
83+
"For example:\n",
84+
"\n",
85+
"- If you predict at **admission**, you may only use variables available at admission\n",
86+
"- Later time points allow more information, but also introduce the risk of **data leakage**\n",
87+
"\n",
88+
"This reflects a key challenge in clinical machine learning:\n",
89+
"\n",
90+
"> Predictions must be based only on information that is available at the time the decision is made.\n",
91+
"\n",
92+
"---\n",
93+
"\n",
94+
"**Potential clinical use:**\n",
95+
"\n",
96+
"- early identification of patients at risk of chronic heart failure\n",
97+
"- timely initiation of preventive or therapeutic interventions\n",
98+
"- improved long-term management and follow-up planning\n",
99+
"\n"
100+
]
101+
},
102+
{
103+
"cell_type": "markdown",
104+
"id": "adba14f57b7e6300",
105+
"metadata": {},
106+
"source": [
107+
"## Your Tasks\n",
108+
"\n",
109+
"- Load and explore the dataset to understand its structure and contents\n",
110+
"- Decide at which time point you want to predict the ventricular fibrillation (target variable = \"FIBR_JELUD\") \\\n",
111+
" Adjust your feature selection accordingly\n",
112+
"- Prepare the data for machine learning\n",
113+
"- Train and compare different models (e.g. Logistic Regression, Random Forest, XGB)\n",
114+
"- Evaluate model performance using appropriate metrics\n",
115+
"- Interpret your results and reflect on their clinical relevance"
116+
]
117+
},
118+
{
119+
"cell_type": "code",
120+
"execution_count": null,
121+
"id": "1cea35a00ae1f801",
122+
"metadata": {},
123+
"outputs": [],
124+
"source": [
125+
"# Import bia-bob as a helpful Python & Medical AI expert\n",
126+
"from bia_bob import bob\n",
127+
"import os\n",
128+
"\n",
129+
"bob.initialize(\n",
130+
" endpoint=os.getenv('ENDPOINT_URL'),\n",
131+
" model=\"vllm-llama-4-scout-17b-16e-instruct\",\n",
132+
" system_prompt=os.getenv('SYSTEM_PROMPT_MEDICAL_AI')\n",
133+
")"
134+
]
135+
},
136+
{
137+
"cell_type": "code",
138+
"execution_count": null,
139+
"id": "e70c2e2c406e2035",
140+
"metadata": {},
141+
"outputs": [],
142+
"source": [
143+
"# %bob Who are you? Just one sentence!"
144+
]
145+
}
146+
],
147+
"metadata": {
148+
"kernelspec": {
149+
"display_name": "Python 3",
150+
"language": "python",
151+
"name": "python3"
152+
},
153+
"language_info": {
154+
"codemirror_mode": {
155+
"name": "ipython",
156+
"version": 2
157+
},
158+
"file_extension": ".py",
159+
"mimetype": "text/x-python",
160+
"name": "python",
161+
"nbconvert_exporter": "python",
162+
"pygments_lexer": "ipython2",
163+
"version": "2.7.6"
164+
}
165+
},
166+
"nbformat": 4,
167+
"nbformat_minor": 5
168+
}

0 commit comments

Comments
 (0)