POST /predict
Accepts patient health features and returns risk of cardiovascular disease.
Send a JSON payload with these features:
{
"Age": 60,
"Sex": "M",
"ChestPainType": "ASY",
"RestingBP": 160,
"Cholesterol": 0,
"FastingBS": 1,
"RestingECG": "Normal",
"MaxHR": 149,
"ExerciseAngina": "N",
"Oldpeak": 0.4,
"ST_Slope": "Flat"
}
The API expects the features inside a "features" key:
{
"features": {
"Age": 60,
"Sex": "M",
"ChestPainType": "ASY",
"RestingBP": 160,
"Cholesterol": 0,
"FastingBS": 1,
"RestingECG": "Normal",
"MaxHR": 149,
"ExerciseAngina": "N",
"Oldpeak": 0.4,
"ST_Slope": "Flat"
}
}
import requests
API_URL = "https://cardiovascular-diseases-api-761922006747.us-east1.run.app/predict"
# API_URL = "http://localhost:8080/predict"
sample_input = {
"Age": 60,
"Sex": "M",
"ChestPainType": "ASY",
"RestingBP": 160,
"Cholesterol": 0,
"FastingBS": 1,
"RestingECG": "Normal",
"MaxHR": 149,
"ExerciseAngina": "N",
"Oldpeak": 0.4,
"ST_Slope": "Flat"
}
request_data = {"features": sample_input}
response = requests.post(API_URL, json=request_data)
print(f"Status code: {response.status_code}")
print("Prediction:", response.json())
curl -X POST "https://cardiovascular-diseases-api-761922006747.us-east1.run.app/predict" \
-H "Content-Type: application/json" \
-d '{
"features": {
"Age": 60,
"Sex": "M",
"ChestPainType": "ASY",
"RestingBP": 160,
"Cholesterol": 0,
"FastingBS": 1,
"RestingECG": "Normal",
"MaxHR": 149,
"ExerciseAngina": "N",
"Oldpeak": 0.4,
"ST_Slope": "Flat"
}
}'
{
"prediction": "0|1"
}
| Feature Name | Description | Typical Range | Type |
|---|---|---|---|
| Age | Age of the patient [years] | > 0 | Integer |
| Sex | Sex of the patient [M: Male, F: Female] | M / F | Categorical |
| ChestPainType | Chest pain type | TA / ATA / NAP / ASY | Categorical |
| RestingBP | Resting blood pressure [mm Hg] | ~ 90–200 | Integer |
| Cholesterol | Serum cholesterol [mg/dl] | ~ 0–600 | Integer |
| FastingBS | Fasting blood sugar >120 mg/dl | 0 or 1 | Integer |
| RestingECG | Resting electrocardiogram results | Normal / ST / LVH | Categorical |
| MaxHR | Maximum heart rate achieved | 60–202 | Integer |
| ExerciseAngina | Exercise-induced angina | Y / N | Categorical |
| Oldpeak | ST depression induced by exercise | >= 0 | Float |
| ST_Slope | Slope of the peak exercise ST segment | Up / Flat / Down | Categorical |
| HeartDisease | Target variable | 0 = Normal, 1 = Heart disease | Binary |