ANNAS TRI WIDAGDO/PORTFOLIO · 2026
VOL. 01 // TECHNICAL ARCHIVE
■annastriwidagdo.me
SOFTWARE ENGINEER·FULL-STACK WEB DEVELOPER·MACHINE LEARNING ENGINEER
ENTRY 001OPENING TECHNICAL ARCHIVE00% · 01 / 01
Skip to content
■annastriwidagdo.me
  • 01Home
  • 02About
  • 03Projects
  • 04Blog●
  • 05Contact
LANGEN/ID
■annastriwidagdo.me
  • Software Engineer
  • Full-Stack Web Developer
  • Machine Learning Engineer

JAKARTA, INDONESIA · UTC+7

EMAILannastriw6@gmail.com↗ (opens in a new tab)LINKEDIN/in/annastriw↗ (opens in a new tab)GITHUB@annastriw↗ (opens in a new tab)CONTACTOpen Contact→

© 2026 Annas Tri Widagdo. Drafted in grids, shipped in code.

←Back to indexBLOG / 02
[ESSAY // 02]/Applied Machine Learning·3 min read

Integrating Machine Learning into a Web Application

A practical look at connecting iHealth Edu, patient health data, and a separately served Random Forest risk-prediction prototype without blurring the clinical boundary.

Written byAnnas Tri Widagdo
  • #Random Forest
  • #Flask
  • #Laravel
  • #Next.js
  • #Docker
[01]

Preparing the Dataset for Machine Learning

Building a practical health risk prediction tool starts with clean data. The project used a public dataset of 158,355 health records across 22 columns, covering 21 demographic, clinical, and lifestyle indicators with a binary heart_attack target. Categorical features were encoded, and numerical values were normalized with MinMaxScaler so that all features carried balanced weight during training.

To prevent data leakage, the dataset was split 80:20 (126,684 training rows and 31,671 test rows) using stratified sampling. SMOTE was applied only to the training set to handle class imbalance, balancing it to 151,766 samples while keeping the test set completely untainted. Hyperparameter tuning with RandomizedSearchCV evaluated F1-Scores across four algorithms: Random Forest, Linear SVM, K-Nearest Neighbors, and Logistic Regression.

Dataset
158,355 rows / 22 columns
Stratified split
80:20
Random Forest accuracy
71.93%
Random Forest ROC-AUC
0.8015
Documented output from the heart-attack risk-prediction prototype
Evaluation visual showing documented risk-prediction inference output and feature metrics.
[02]

Serving Predictions via a Standalone Flask API

  1. 01Patient Health Data in iHealth Edu
  2. 02Laravel Application Backend
  3. 03Flask REST API Microservice
  4. 04Serialized Preprocessing Artifacts
  5. 05Random Forest Inference
  6. 06Structured Risk Payload

In iHealth Edu, developed in collaboration with Puskesmas Padangsari in Semarang, patient screening, educational modules, health records, and ESP32 IoT biometrics live inside a Next.js and Laravel web application. Instead of running Python models directly inside the web server, the machine learning workflow was separated into its own lightweight Flask REST API.

Using Joblib, the trained Random Forest model artifact (.pkl), MinMaxScaler, and feature mapping dictionaries were saved together. This ensures that live incoming patient data undergoes the exact same mathematical transformations computed during offline training. The Flask service was containerized with Docker and deployed on a Linux Ubuntu server.

[03]

Translating Probabilities into Useful Decision Support

Random Forest was chosen for the prototype because it achieved the highest documented accuracy of 71.93% and the highest ROC-AUC of 0.8015 among compared algorithms, even though Logistic Regression scored highest in F1 (0.6618) and KNN in recall (70.40%).

When an authorized health worker inputs patient vitals, the Flask API returns a structured JSON response containing the predicted risk category, calculated numerical probability, contextual rule-based risk factors, and global top-5 feature importances. The frontend displays these indicators as helpful visual context within the broader patient history record.

Documented patient-facing interface from iHealth Edu
The prediction workflow sits inside a broader patient, screening, education, and health-record system.
[04]

Clear Medical Boundaries and Practical Impact

Health limitation

This implementation is a risk-prediction and decision-support prototype. It is not a clinical diagnosis, does not replace a health professional, and has no documented clinical validation.

  • Present predictions and probability scores as statistical indicators rather than medical diagnoses.
  • Display rule-based risk factors as helpful reference points rather than definite causes.
  • Treat top feature importances as global model insights, not individualized medical advice.
  • Protect patient records through strict role-based access control.

Machine learning in healthcare is most useful when its limits are clearly communicated. By pairing solid model training with transparent decision support, the platform provides helpful early risk insights while keeping clinical judgment firmly in the hands of healthcare professionals.

Related project experience

iHealth Edu↗Machine Learning Model for Heart Attack Risk Prediction↗
← PREVIOUS ARTICLEBuilding a Multi-Branch ERP from Workflow to Production
All Articles
NEXT ARTICLE →From Android Print Framework to ESC/POS