ADR project done
An AI that predicts whether a reported drug side effect is serious, and explains why.
300K+ FDA reports · XGBoost · 88% accuracy · SHAP explanations
Code: https://t.co/6RZisW8u3d
Next: what the model gets wrong.
#BuildInPublic#MachineLearning
The code behind the rule, and when the alert turned on in my test clip.
Video source: "Burning 1000000 firecrackers At a Time | China's Festival" (YouTube)
My detector stayed silent through thousands of red firecrackers. Then the smoke rose.
The rule: fire or smoke in 5 of the last 10 frames, so one odd frame can't set it off.
Day 14 of computer vision.
#BuildInPublic#ComputerVision
Computer vision, Day 13: the key number isn't in the model.
It's the threshold.
Default 0.5: 15% of fire/smoke images raise no alert.
Smoke 0.30, fire 0.35: only 6% missed. False alarms 0.6% → 2.1%.
A missed fire costs more than a false alarm.
#BuildInPublic#ComputerVision
Computer vision, Day 12: the test it never saw.
4,306 unseen images. mAP50:
• Smoke 0.82
• Fire 0.69
I expected fire to be easier. It isn't. Smoke is big. Flames in a wide shot are a few pixels, and it misses about 4 in 10 fire boxes.
#BuildInPublic#ComputerVision
Computer vision, Day 11: training.
Not from zero. YOLOv8n already knows edges and shapes from COCO. I taught it two new words: smoke, fire.
50 epochs, 2.1 hours on a laptop GPU. mAP50: 0.41 → 0.77.
Most of it came in the first 20 epochs.
#BuildInPublic#ComputerVision
Computer vision, Day 10: the dataset.
D-Fire: 21,527 images. The surprise: 46% have no fire or smoke.
On purpose: sunsets, fog, lamps. Without them it learns "orange = fire" and panics at sunsets. Split: 14,122 train, 3,099 val, 4,306 test.
#BuildInPublic#ComputerVision
Computer vision, Day 9: from learning to building.
Cameras record, but nobody watches every feed live. Fire spreads in minutes.
So I'm building a detector that spots fire and smoke on camera and raises the alert itself.
Plan in the image.
#BuildInPublic#ComputerVision
Computer vision, Day 8: how do you grade a box?
IoU = overlap ÷ combined area. My label vs YOLO's box: 0.92. Above 0.5 = correct.
Then count:
• Precision 0.62: its boxes that are right
• Recall 0.83: real objects it found
#BuildInPublic#ComputerVision
Computer vision, Day 7: what a model learns from.
Not images. Text files.
This zebra is one line:
22 0.346 0.493 0.689 0.892
class, centre x, centre y, width, height
Thousands of these lines are the teacher. Sloppy boxes = a sloppy model.
#BuildInPublic#ComputerVision
Computer vision, Day 5: YOLO (You Only Look Once).
It finds every object in a single pass over the image.
I ran it on 4 photos at once: cat, cup, table, person. Under 10 ms.
But it missed the rocket. It only finds what it was trained on.
#BuildInPublic#ComputerVision
Computer vision, Day 6: the confidence threshold.
Same photo, same model, two settings:
• 0.25: 8 boxes, incl. weak guesses at 0.26 and 0.31
• 0.70: 1 box (a potted plant). Both horses gone.
Too low = junk boxes. Too high = missed objects.
#BuildInPublic#ComputerVision
Computer vision, Day 4: classification vs detection.
Classification: one label for the whole image. "cup"
Detection: every object, each with a box. "cup 92%, table 72%"
Classification tells you what. Detection tells you what and where.
#BuildInPublic#ComputerVision
Computer vision, Day 3: HSV colour.
RGB mixes colour and brightness together. HSV splits them:
• Hue: which colour
• Saturation: how vivid
• Value: how bright
So "find everything orange" becomes one range on Hue, even when the lighting changes.
#BuildInPublic#ComputerVision
Computer vision, Day 2: OpenCV basics.
A few lines and you can:
• read an image: cv2.imread()
• resize it: cv2.resize()
• make it grey: cv2.cvtColor()
• open your webcam: cv2.VideoCapture(0)
Fun gotcha: OpenCV stores colours as BGR, not RGB.
#BuildInPublic#ComputerVision
@Xjohannesh Maybe! Most misses are close calls (30-50%), so a lower threshold for those reports could catch a lot of them. More data would help dupilumab too, so it sees more serious cases. Moving on to computer vision for now.
ADR project done
An AI that predicts whether a reported drug side effect is serious, and explains why.
300K+ FDA reports · XGBoost · 88% accuracy · SHAP explanations
Code: https://t.co/6RZisW8u3d
Next: what the model gets wrong.
#BuildInPublic#MachineLearning
Computer vision, Day 1: what an image is to a computer.
Just a grid of numbers. Every pixel = 3 values (red, green, blue), from 0 to 255.
This small photo alone is 405,900 numbers.
#BuildInPublic#ComputerVision