Views
No views yet
No diabetes class or the Prediabetes or diabetes class, and returns the estimated probability for the positive class.0 = no diabetes, 1 = prediabetes or diabetesPrediabetes or diabetesmodels/random_forest_undersampling_ensemble_threshold_060.joblibensemble: estimators and serving metadatafeature_columns: expected feature ordertarget_definition: label definitiontest_metrics: evaluation summary| Feature | Type | Description |
|---|---|---|
HighBP | integer | High blood pressure indicator, usually 0 or 1. |
HighChol | integer | High cholesterol indicator, usually 0 or 1. |
CholCheck | integer | Cholesterol check indicator, usually 0 or 1. |
BMI | float | Body mass index. |
Smoker | integer | Smoking history indicator, usually 0 or 1. |
Stroke | integer | Stroke history indicator, usually 0 or 1. |
HeartDiseaseorAttack | integer | Heart disease or heart attack history indicator, usually 0 or 1. |
PhysActivity | integer | Physical activity indicator, usually 0 or 1. |
Fruits | integer | Fruit consumption indicator, usually 0 or 1. |
Veggies | integer | Vegetable consumption indicator, usually 0 or 1. |
HvyAlcoholConsump | integer | Heavy alcohol consumption indicator, usually 0 or 1. |
AnyHealthcare | integer | Healthcare coverage/access indicator, usually 0 or 1. |
NoDocbcCost | integer | Could not see a doctor because of cost indicator, usually 0 or 1. |
GenHlth | integer | General health category. |
MentHlth | integer | Number of poor mental health days. |
PhysHlth | integer | Number of poor physical health days. |
DiffWalk | integer | Difficulty walking indicator, usually 0 or 1. |
Sex | integer | Encoded sex category. |
Age | integer | Encoded age category. |
Education | integer | Encoded education category. |
Income | integer | Encoded income category. |
1{
2 "prediction": 1,
3 "diabetes_probability": 0.7342,
4 "prediction_label": "Prediabetes or diabetes"
5}diabetes_probability is the average positive-class probability across the ensemble. The final class is 1 when this probability is greater than or equal to 0.60.| Metric | Value |
|---|---|
| Negative precision | 0.9376 |
| Negative recall | 0.7521 |
| Positive precision | 0.3559 |
| Positive recall | 0.7323 |
| Positive F1 | 0.4791 |
| Macro F1 | 0.6569 |
| Balanced accuracy | 0.7422 |
pip install -r requirements.txtuvicorn main:app --host 0.0.0.0 --port 80001curl -X POST "http://localhost:8000/predict" \
2 -H "Content-Type: application/json" \
3 -d @sample_input.jsonpython inference.py1import joblib
2import pandas as pd
3
4artifact = joblib.load("models/random_forest_undersampling_ensemble_threshold_060.joblib")
5ensemble = artifact["ensemble"]
6feature_columns = artifact["feature_columns"]
7
8row = {
9 "HighBP": 1,
10 "HighChol": 1,
11 "CholCheck": 1,
12 "BMI": 31.5,
13 "Smoker": 0,
14 "Stroke": 0,
15 "HeartDiseaseorAttack": 0,
16 "PhysActivity": 1,
17 "Fruits": 1,
18 "Veggies": 1,
19 "HvyAlcoholConsump": 0,
20 "AnyHealthcare": 1,
21 "NoDocbcCost": 0,
22 "GenHlth": 3,
23 "MentHlth": 2,
24 "PhysHlth": 4,
25 "DiffWalk": 0,
26 "Sex": 1,
27 "Age": 9,
28 "Education": 5,
29 "Income": 6
30}
31
32input_df = pd.DataFrame([row])[feature_columns]
33probability = sum(
34 estimator.predict_proba(input_df)[0][1]
35 for estimator in ensemble["estimators"]
36) / len(ensemble["estimators"])
37prediction = int(probability >= ensemble["threshold"])
38label = ensemble["class_mapping"][prediction]1.
2├── app/
3│ └── schemas.py
4├── models/
5│ └── random_forest_undersampling_ensemble_threshold_060.joblib
6├── src/
7│ └── model_features.py
8├── inference.py
9├── main.py
10├── requirements.txt
11└── sample_input.json