All production endpoints are strictly routed under the /heartflow namespace.
Telemetry stays on the client during normal use. Session logs are kept in browser memory and are not sent to any database without a manual retrain upload.
Endpoints accept and return JSON. Generated C files use standard C99 without malloc calls, making them suitable for microcontrollers.
/heartflow/healthSystemEvaluates health status, loaded scikit-learn classifiers (RF, SVM, LogReg, Small NN, KNN), and retraining pipeline capability.
curl -X GET "https://idkhowtocodefr-hf-backend.hf.space/heartflow/health"{
"status": "Healthy",
"models_loaded": true,
"models": {
"rf": true,
"svm": true,
"logreg": true,
"small_nn": true,
"knn": true
},
"retrain_enabled": true
}/heartflow/predictInferenceEvaluates vital signs against the 5-model ensemble to predict cardiovascular risk and class probabilities.
curl -X POST "https://idkhowtocodefr-hf-backend.hf.space/heartflow/predict" \
-H "Content-Type: application/json" \
-d '{
"Heart_Rate": 84,
"SpO2_Level": 97.5,
"Systolic_BP": 132,
"Diastolic_BP": 86,
"Body_Temp": 37.1
}'{
"Heart_Rate": 84,
"SpO2_Level": 97.5,
"Systolic_BP": 132,
"Diastolic_BP": 86,
"Body_Temp": 37.1
}{
"prediction": false,
"prediction_label": "Healthy",
"probability": 0.89,
"ensemble_prediction": false,
"model_outputs": {
"rf": "Healthy",
"svm": "Healthy",
"logreg": "Healthy",
"small_nn": "Healthy",
"knn": "Healthy"
},
"model_probs": {
"rf": 0.635,
"svm": 0.994,
"logreg": 0.919,
"small_nn": 0.995,
"knn": 1
},
"disease_probs": {
"Healthy": 0.89,
"Diabetes Mellitus": 0.061,
"Normal": 0.046,
"Hypertension": 0.0018
},
"weights": {
"rf": 0.25,
"small_nn": 0.25,
"logreg": 0.2,
"knn": 0.15,
"svm": 0.15
}
}/heartflow/explainInferenceCalculates local Shapley additive explanations (TreeSHAP) against the Random Forest classifier to provide feature attribution vectors.
curl -X POST "https://idkhowtocodefr-hf-backend.hf.space/heartflow/explain" \
-H "Content-Type: application/json" \
-d '{
"Heart_Rate": 84,
"SpO2_Level": 97.5,
"Systolic_BP": 132,
"Diastolic_BP": 86,
"Body_Temp": 37.1
}'{
"Heart_Rate": 84,
"SpO2_Level": 97.5,
"Systolic_BP": 132,
"Diastolic_BP": 86,
"Body_Temp": 37.1
}{
"shap_values": [
0.124,
-0.045,
0.082,
-0.012,
0.003
],
"feature_names": [
"Heart Rate (bpm)",
"SpO2 Level (%)",
"Systolic Blood Pressure (mmHg)",
"Diastolic Blood Pressure (mmHg)",
"Body Temperature (°C)"
]
}/heartflow/metricsSystemRetrieves macro-F1, global accuracy, per-model evaluation scores, and active ensemble voting weights.
curl -X GET "https://idkhowtocodefr-hf-backend.hf.space/heartflow/metrics"{
"ensemble_accuracy": 0.962,
"ensemble_f1_macro": 0.948,
"latency_microsec_edge": 18.4,
"models": {
"rf": {
"accuracy": 0.954,
"f1": 0.938,
"weight": 0.25
},
"small_nn": {
"accuracy": 0.949,
"f1": 0.931,
"weight": 0.25
},
"logreg": {
"accuracy": 0.928,
"f1": 0.912,
"weight": 0.2
},
"knn": {
"accuracy": 0.935,
"f1": 0.919,
"weight": 0.15
},
"svm": {
"accuracy": 0.941,
"f1": 0.925,
"weight": 0.15
}
}
}/heartflow/historySystemFetches logged patient vitals, timestamps, and model prediction outcomes from the SQLite audit database.
curl -X GET "https://idkhowtocodefr-hf-backend.hf.space/heartflow/history"[
{
"id": 1,
"timestamp": "2026-10-18 22:45:10",
"heart_rate": 78,
"spo2": 98.5,
"sys_bp": 120,
"dia_bp": 80,
"temp": 37,
"prediction_label": "Healthy",
"confidence": 0.96
}
]/heartflow/dataset?page=1&limit=25DataQueries the 60,000-record clinical dataset with server-side pagination, disease category filtering, and keyword search.
curl -X GET "https://idkhowtocodefr-hf-backend.hf.space/heartflow/dataset?page=1&limit=25"{
"total": 60000,
"page": 1,
"limit": 25,
"total_pages": 2400,
"rows": [
{
"id": 1,
"Heart_Rate": 72,
"SpO2_Level": 98,
"Systolic_BP": 118,
"Diastolic_BP": 78,
"Body_Temp": 36.8,
"Disease": "Normal"
}
]
}/heartflow/dataset/summaryDataProvides precomputed mean, standard deviation, distribution percentiles, target distributions, and feature correlation matrix.
curl -X GET "https://idkhowtocodefr-hf-backend.hf.space/heartflow/dataset/summary"{
"summary": {
"total_records": 60000,
"features": 5,
"classes": 6
},
"target_distribution": {
"Healthy": 14200,
"Heart Disease": 12800,
"Hypertension": 11500
},
"correlation_matrix": {
"Heart_Rate": {
"Systolic_BP": 0.42,
"SpO2_Level": -0.38
}
}
}/heartflow/dataset/downloadDataStreams the full 60,000-observation clinical CSV dataset as an RFC 4180 file attachment.
curl -O -J "https://idkhowtocodefr-hf-backend.hf.space/heartflow/dataset/download"{
"content-type": "text/csv",
"filename": "patient_dataset.csv",
"records": 60000
}/heartflow/export_tinyml?model_name=rf&quantize=falseExportCompiles trained ensemble models (RF, SVM, LogReg, Small NN, KNN) to ANSI C99 headers with optional INT8 fixed-point quantization for microcontrollers.
curl -X GET "https://idkhowtocodefr-hf-backend.hf.space/heartflow/export_tinyml?model_name=rf&quantize=false"{
"model_name": "rf",
"quantized": false,
"sram_bytes": 1024,
"code": "#ifndef HEARTFLOW_MODEL_H\n#define HEARTFLOW_MODEL_H\n\n// Deterministic Static C99 ABI\n..."
}/heartflow/retrainMLOpsUploads an external batch CSV and starts background retraining across the 5 classifiers with memory hot-swapping.
curl -X POST "https://idkhowtocodefr-hf-backend.hf.space/heartflow/retrain" \
-F "file=@clinical_cohort_update.csv"{
"status": "success",
"message": "Dataset uploaded and ensemble retrain started in background!"
}/heartflow/retrain/statusMLOpsReturns live stage progress, active model version, and fitted F1-scores during background retraining.
curl -X GET "https://idkhowtocodefr-hf-backend.hf.space/heartflow/retrain/status"{
"status": "complete",
"progress": 100,
"stage": "Active Model Hot-Swapped",
"current_step": "Ensemble ready for inference",
"total_models": 5,
"active_version": "2.1.0",
"models_trained": [
"rf",
"svm",
"logreg",
"small_nn",
"knn"
],
"f1_scores": {
"rf": 0.985,
"svm": 0.962,
"logreg": 0.941,
"small_nn": 0.973,
"knn": 0.98
}
}/heartflow/ws/feedInferenceBi-directional WebSocket stream emitting continuous 4Hz patient vitals (HR, SpO2, BP, Temp) alongside real-time ensemble inference alerts.
wscat -c "wss://idkhowtocodefr-hf-backend.hf.space/heartflow/ws/feed"{
"sensor_data": {
"Heart_Rate": 78.5,
"SpO2_Level": 98.2,
"Systolic_BP": 122,
"Diastolic_BP": 81,
"Body_Temp": 37
},
"prediction": {
"is_at_risk": 0,
"label": "Healthy",
"confidence": 0.945,
"disease_probs": {
"Healthy": 0.945,
"Heart Disease": 0.02
}
}
}