cd /news/machine-learning/i-trained-a-neural-network-on-real-m… Β· home β€Ί topics β€Ί machine-learning β€Ί article
[ARTICLE Β· art-34637] src=dev.to β†— pub= topic=machine-learning verified=true sentiment=↑ positive

I Trained a Neural Network on Real Medical Data and Fit It in 8.9 kB of Pure C

An engineer trained a neural network on 3,658 real patient records from the Framingham Heart Study and fit it into 8.9 kB of pure C code using Hasaki, a command-line tool for embedded systems. The model predicts systolic blood pressure with a mean absolute error of approximately 7.8 mmHg, achieving clinical-grade accuracy on a single test sample. The project demonstrates regression capabilities in Hasaki, which was previously only tested on classification tasks.

read5 min views1 publishedJun 20, 2026

I want to be honest with you from the start: I didn't set out to write this article.

I set out to answer a question I had about my own tool β€” can Hasaki do regression? β€” and somewhere between a dataset of 3,658 real patient records and watching a microcontroller predict blood pressure from 14 numbers, I realized the answer deserved to be written down.

Hasaki is a command-line neural network trainer I built for embedded systems developers. You train a model on your desktop, and it exports a self-contained C header β€” weights, biases, and a predict()

function β€” ready to drop into any MCU project. No TensorFlow. No runtime. No dependencies.

Every public demo I've done has been classification: smoke detection, MNIST digits, motion sensing. Binary or multiclass outputs. But Hasaki has a linear

activation. And sigmoid

. And a single-neuron output layer. The pieces for regression were always there.

I just never tested them.

So I decided to test them properly β€” with real data, a real target, and enough honesty to document what broke along the way.

I wanted something biomΓ©dical. Not because I'm building a medical device β€” I'm not, and I'll be clear about that β€” but because medical data carries weight. It's messy, it's human, and if the numbers are wrong, they mean something.

The Framingham Heart Study dataset on Kaggle fit the criteria: 4,240 patient records with 15 attributes β€” age, cholesterol, BMI, glucose, smoking habits, blood pressure β€” collected over decades from residents of Framingham, Massachusetts. The target most people use is TenYearCHD

, a binary classification of 10-year heart disease risk.

I ignored that. I went after sysBP

β€” systolic blood pressure β€” a continuous value ranging from 83.5 to 295.0 mmHg. That's a regression problem.

Before Hasaki could see a single number, I had to clean the data.

645 rows had missing values β€” about 15% of the dataset. I dropped them. That left 3,658 samples, which is workable.

Then I had to normalize everything. Hasaki expects inputs in a consistent range. Raw features don't come that way: age runs 32–70, cholesterol 107–696, glucose 40–394. I used RobustScaler

from scikit-learn β€” more resistant to outliers than MinMaxScaler

, which matters when you have 3,658 people's real health data.

The target needed normalization too. With sigmoid

as the output activation, predictions are bounded to [0, 1]

. So I normalized sysBP

to that range:

y_scaled = (target - target_min) / (target_max - target_min)

This is the part that frustrates me about my own tool. A new user shouldn't need to know any of this. They should hand Hasaki a CSV and get a model. That's a v4.0.0 problem β€” and it's already on the roadmap.

Architecture: 14,32,16,1

β€” fourteen inputs, two hidden layers, one output.

hasaki -d 14,32,16,1 -act relu,relu,sigmoid -a train \
      -f framingham_hasaki.csv -e 10000 -l 0.001 --adam \
      -o bp_model.txt

It trained in 23 seconds. Early stopping triggered at epoch 218.

Final Val Loss: 0.002420

That number lives in normalized space. To make it mean something:

RMSE = sqrt(0.002420) Γ— (295.0 - 83.5) β‰ˆ 10.4 mmHg

The mean absolute error across the validation set was approximately 7.8 mmHg.

For a single sample β€” a male patient, age 39, non-smoker, no diabetes, cholesterol 195, BMI 26.97 β€” the model predicted 107.4 mmHg. The real value was 106.0 mmHg. Error: 1.4 mmHg.

Clinical-grade blood pressure monitors are rated at Β±3 mmHg.

There's something I need to flag for anyone using Hasaki for regression: the training log shows Train Acc

and Val Acc

alongside the loss values. During my regression run, both read 1.0000

from the very first epoch.

That's not because the model is perfect. It's because the accuracy metric uses a 0.5 threshold designed for binary classification β€” and in regression, nearly every prediction clears that bar trivially.

The accuracy columns are meaningless for regression. Ignore them. Watch Val Loss.

This is a known issue and it's going in the fix list for v4.0.0.

After validating, I ran the INT8 quantization test:

Result: PASSED
Mean error (float):  0.037270
Mean error (INT8):   0.037251

Practically identical. I exported:

hasaki -m bp_model.txt -a export -o bp_model.h -q int8

File size: 8,893 bytes β€” 8.9 kB.

A model that predicts systolic blood pressure from 14 patient vitals, quantized to INT8, fits in 8.9 kB of flash. No runtime. No interpreter. No Python at inference time. Just a C header and a predict()

call.

#include "bp_model.h"

float input[14] = { /* normalized vitals */ };
float output[1];

predict(input, output);

float systolic_bp = output[0] * (295.0f - 83.5f) + 83.5f;

I built Hasaki for classification. I documented it for classification. Every demo I've published has been classification.

Regression was never a stated feature. It was a consequence of having linear

and sigmoid

activations and a single output neuron β€” the right pieces in the right place.

I only found out it worked by testing it.

That surprised me more than the 1.4 mmHg prediction. Not because the math is surprising β€” a neural network doesn't care if the target is a class label or a blood pressure reading. But because the tool had a capability I didn't know it had until I used it outside its intended purpose.

There's something worth sitting with there. We tend to define our tools by the problems we built them for. But a good tool, used honestly, sometimes reveals what it can do before we think to ask.

I didn't know Hasaki could do regression.

Now it's in the manual.

This is a research experiment, not a medical device. The model was trained on the Framingham Heart Study dataset for demonstration purposes only. Do not use Hasaki-trained models for clinical diagnosis without independent validation by qualified medical professionals.

Hasaki εˆƒε…ˆ β€” Small tools. Sharp inference.

Hasaki εˆƒε…ˆ Free Β· Hasaki εˆƒε…ˆ Pro

── more in #machine-learning 4 stories Β· sorted by recency
── more on @hasaki 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/i-trained-a-neural-n…] indexed:0 read:5min 2026-06-20 Β· β€”