711.56K
AI

Group 3 - Saad hassan and Maleeha Fatima (final)

1.

GENERATIVE AI (AI-542) · MODEL RESULTS: NAIVE BAYES · VAE · HMM
What can I eat now?
FROM LAB REPORT
TO DINNER PLATE
AI-Powered Patient Diet and Lifestyle Support from Lab
Reports and Prescriptions
Saad Hassan 2026-MS-AI-110
Maleeha Fatima 2026-MS-AI-107
Group No. 3
Instructor: Dr Syed Khaldoon Khurshid · IDEAL Labs, UET Lahore
Three models will help!

2.

PROJECT PITCH AND ARCHITECTURE
One health mentor: report + prescription in, a simple daily health guide out
THE PITCH
1
UPLOAD
Problem: after a 5-minute visit, patients forget the advice and can't read their own report.
Our answer: upload the report + prescription, get a personal guide backed by trusted sources. The doctor's plan
always comes first.
2
READ
3
RETRIEVE
4
GENERATE
OUTPUT
Personal Health Guide
Gradio app
PyMuPDF + OCR
RAG: embeddings + FAISS
LLM + safety rules
Lab report, prescription,
age and food habits
Pulls out test, value,
normal range, medicine
and dose
Finds matching guidance
from WHO and NHS
sources
Writes the guide. Never
diagnoses or changes a
dose
OUR 3 MODELS
NAIVE BAYES
checks each food in the
diet plan
VAE
makes fake patients to
test the app safely
HMM
Report explained
Daily diet plan
Lifestyle + precautions
When to call the doctor
tracks sugar between
visits, alerts doctor
2

3.

TODAY: THREE MODELS, THREE JOBS
Each model answers one simple question inside our health mentor
NAIVE BAYES
VAE
HMM
The Food Judge
The Patient Factory
The Health Tracker
“Is this food safe for this patient?”
“How do we test our app without using
real patients' private reports?”
“How is the patient doing between doctor
visits?”
Result on slide 4
Result on slide 5
Setup on slides 6 and 7
3

4.

THE FOOD JUDGE ON TRIAL
Naive Bayes result: can it tell safe foods from unsafe ones for a diabetic patient?
SCOREBOARD · 60 FOODS
Old rule
Naive Bayes
72%
VS
WHERE THE JUDGE WENT WRONG
Green = right answer, red = mistake
57%
Two foods fooled the judge.
Which two?
Judge says →
96%
accuracy
Truly not
suitable
92%
Not suitable
Suitable
28
2
A Kheer
B Dates (big portion)
C Samosa
unsafe foods caught
D Banana shake
Truly suitable
0
30
Old rule: “Avoid anything with high sugar”
Both mistakes call an unsafe food safe: the risky
direction, so the safety check stays on
Naive Bayes: sugar + fried + fibre + refined
carb · 0.3 ms for 60 foods
YOUR TURN
E Brown rice
B and D. Same features as fruit chaat, so
P(suitable) = 0.91. Missing feature: portion
size
Tested 100 times on foods it had not seen (5-fold cross-validation × 20) · labels from general diabetic diet advice
4

5.

THE PATIENT FACTORY
VAE result: realistic fake patients, so we can test our app without anyone's private report
724 real patients
Encoder
z
Decoder
2,000 new patients
Pima diabetes data
squeezes a patient
into 3 numbers
builds a new patient
never existed
YOUR TURN
Fasting glucose (mg/dL): share of patients, %
Only one of these patients is real. Which one?
Real patients
Patient A
Glucose 162
BP 59
BMI 29.2
Age 42
Patient B
Patient C
Glucose 115
BP 98
BMI 24.0
Age 34
Glucose 120
BP 85
BMI 27.0
Age 49
VAE patients
25
20
15
10
5
MADE BY VAE
REAL
MADE BY VAE
0
50
0.854
score of a model that
learned only from fake
patients (real: 0.876, max 1)
±2
mg/dL gap in mean glucose
(120 vs 122)
0
70
copied patients · 0
impossible values
90
110
130
Weak spot
150
170
190
spread too narrow: few
patients below 80
mg/dL
5

6.

WHAT HAPPENS BETWEEN VISITS?
HMM setup (1/2): the true health state is hidden, we only see daily sugar readings
HIDDEN: WHAT WE CAN'T SEE
THE SETUP: 5 PARTS
0.15
0.20
Controlled
Borderline
Uncontrolled
stays 0.80
stays 0.60
stays 0.70
0.20
0.25
Direct jump Controlled
Uncontrolled: 0.05 each way
SEEN: WHAT EACH STATE LOGS
States
3 hidden: C, B, U
Observations
1 per day: N, H or V
Day 1 (π)
0.6 · 0.3 · 0.1 (just treated)
Change (A)
arrows: chance of moving state
Reading (B)
bars: chance of each reading
.80
.65
.50
.30
.15
N
H
.05
V
.30
.20
YOUR TURN
.05
N
H
V
N under 130 · H 130–180 · V over 180 mg/dL (fasting)
N
H
V
N
H
H
V
V
V
H
Day 7 drops back to H. Is the patient back in control? Hands
up: yes or no
6

7.

HOW THE HMM RUNS
HMM setup (2/2): three steps that turn daily readings into a doctor alert
1 LEARN
2 SCORE
3 DECODE
Baum-Welch (EM)
Forward algorithm
Viterbi algorithm
Learns the arrows and bars from each patient's
own readings. Up to 100 rounds, 5 fresh starts
Asks: how normal is this week? Chance = 0.00073.
A very strange week → ask the patient to re-check
the meter
Picks the most likely hidden state for each day. This
is what triggers the doctor alert
ANSWER: THE WEEK, DECODED BY VITERBI
Alert from day 5: 2 days uncontrolled
Day
1
2
3
4
5
6
7
Patient logs
N
H
H
V
V
V
H
Hidden state
Controlled
Borderline
Borderline
Uncontrolled
Uncontrolled
Uncontrolled
Uncontrolled
0.01
0.10
0.18
0.62
0.81
0.85
0.54
Chance uncontrolled
Still uncontrolled
on day 7.
One better reading
is not recovery
Settings: 1 step = 1 day · 14-day sliding window · the HMM only raises a “contact your doctor” alert, it never changes medicine
7

8.

THREE MODELS, ONE MENTOR
Comparative study: Naive Bayes vs VAE vs HMM in our health mentor
Naive Bayes
VAE
HMM
the Food Judge
the Patient Factory
the Health Tracker
Job in our mentor
Picks foods that suit the patient's
condition
Makes synthetic patients to test the
mentor safely
Tracks the hidden control state between
visits
Data it reads
Food features: sugar, fried, fibre, refined
carb
Lab values: glucose, BP, BMI, age
Daily sugar logs, in time order
How it learns
Counting (+1 so nothing is zero)
Squeeze, rebuild, compare (ELBO loss)
Guess, check, improve (Baum-Welch)
Explainable?
High: every probability visible
Low: a hidden 3-number code
Medium: states + transition table
Our result
96.1% accuracy (old rule 71.7%)
Fake-trained model: 0.854 vs 0.876
Alert on day 5, held on day 7
Weak spot
Blind to portion size
Squeezes out extreme patients
Remembers only yesterday
8

9.

THANK YOU
Naive Bayes
picks safe foods: 96% correct vs 72% for the old rule
VAE
makes realistic fake patients to test our app safely
HMM
tracks the patient between visits and alerts the
doctor
Saad Hassan · Maleeha Fatima · Group 3
Finally, a plan I understand!
English     Русский Правила