⚠️ IMPORTANT CLINICAL DISCLAIMER: The underlying machine learning model is trained entirely on synthetic, machine-generated data, not real-world patient records. This application is built as a proof-of-concept for educational and portfolio demonstration purposes only. It should NOT be used for actual medical diagnosis, screening, or clinical decision-making. Always consult a certified healthcare professional for medical advice.DATASET: https://www.kaggle.com/datasets/jabirmuktabir/stunting-wasting-dataset
Stuntify API is the high-performance backend engine designed to power the Stuntify ecosystem.
Built with FastAPI, this service provides real-time stunting risk assessment with minimal latency. Unlike traditional scripts, this API implements a rigorous MLOps Inference Pipeline that strictly validates data types via Pydantic and orchestrates multiple serialized artifacts to ensure production-grade reliability.
The system acts as a centralized inference unit. It reconstructs the exact mathematical environment used during training by synchronizing 4 key artifacts:
- Gender Encoder: Translates categories (
Laki-laki) into machine vectors. - Standard Scaler: Normalizes anthropometric data (
Age,Height,Weight) to the model's expected distribution. - Classifier Model: The optimized machine learning model (
.joblib). - Target Decoder: Translates the mathematical prediction back to human-readable labels (e.g.,
Severely Stunted).
- Strict Schema Validation: Uses Pydantic Models to enforce data integrity. If a user sends a string for
ageinstead of an integer, the API rejects it immediately with a clear error message. - Smart Error Handling: Global exception handlers ensure the server never crashes on bad inputs, returning meaningful HTTP 400/500 codes.
- CORS Enabled: Fully configured to serve requests from any frontend (React, Vue, Mobile) without cross-origin issues.
Because it is built on FastAPI, Stuntify provides free, interactive documentation (Swagger UI) out of the box. Developers can test endpoints directly in the browser without writing a single line of code.
- Framework: FastAPI (Asynchronous & High Performance)
- Validation: Pydantic
- Computation: NumPy, Scikit-Learn, Joblib
- Deployment: Hugging Face Spaces (Dockerized)
- Ingestion: API receives JSON payload ->
ConditionInputPydantic Model. - Validation: Data types and required fields are verified.
- Loading: Global artifacts are loaded into memory (Lazy Loading pattern).
- Preprocessing:
- Gender string -> Encoded Integer.
- Numerics (Age/Height/Weight) -> Scaled Floats.
- Prediction: The model generates a class index.
- Decoding: Index -> String Label (e.g., "Normal").
https://silvio0-stunting-api.hf.space
- URL:
/predict-stunting - Method:
POST
1. The Request Body (JSON):
{
"jenis_kelamin": "Laki-laki",
"umur": 19,
"tinggi": 91.60,
"berat": 13.30
}
2. The Response (JSON):
{
"prediction": "Severely Stunted"
}
You don't need Postman to test this API. Use the built-in Swagger UI to test directly in your browser:
- Access Docs: https://silvio0-stunting-api.hf.space/docs
- Select Endpoint: Click on the POST /predict-stunting bar.
- Interact: Click "Try it out".
- Input Data: Edit the Request Body JSON.
- Execute: Click the Blue "Execute" button to see the real-time response.
- Clone the Repository
git clone https://github.com/viochris/Stuntify-API.git
cd Stuntify-API- Install Dependencies
pip install -r requirements.txt- Run the Server
uvicorn app:app --reloadOutput: Uvicorn running on http://127.0.0.1:8000
Author: Silvio Christian, Joe "Code that speaks JSON, Logic that saves lives."