Downloads · 30 days
0
RavshanjonEminov/diabetes-risk-prediction
diabetes-risk-prediction is a tabular classification model from RavshanjonEminov. Use it for the tabular classification task on the model card, and read the license before you ship it in a product. It is set up for sklearn. The card lists the license as mit.
A logisticregression pipeline (median imputation → standard scaling → classifier, classweight="balanced") that estimates the probability that a patient has diabetes from 8 routine clinical measurements. Model selectio…
Downloads · 30 days
0
Access
Public
Updated Aug 31, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.skops41.9 KB · 79%
From the Hugging Face model README
A logistic_regression pipeline (median imputation → standard scaling →
classifier, class_weight="balanced") that estimates the probability
that a patient has diabetes from 8 routine clinical measurements. Model
selection, hyperparameters, and the decision threshold were all chosen
by 5-fold cross-validation on the training set — see the search results
below.
This is an educational prototype, not a diagnostic or clinical decision-making tool. Do not use it for real patient care.
The "Use this model" button above may show a snippet based on
skops.hub_utils.download, which was removed in skops >= 0.12 (this model was published with skops 0.14) and will raiseModuleNotFoundErrorif run as-is. Use the snippet below instead — it's verified against this exact repo.
from huggingface_hub import hf_hub_download
import skops.io as sio
import pandas as pd
path = hf_hub_download("RavshanjonEminov/diabetes-risk-prediction", "model.skops")
# numpy.dtype is skops's only flagged type here -- it comes from the
# scaler/imputer's stored statistics arrays, not from executable code.
artifact = sio.load(path, trusted=["numpy.dtype"])
pipeline, threshold = artifact["pipeline"], artifact["threshold"]
patient = pd.DataFrame([{
"Pregnancies": 2, "Glucose": 130, "BloodPressure": 70,
"SkinThickness": 25, "Insulin": 90, "BMI": 28.5,
"DiabetesPedigreeFunction": 0.35, "Age": 45,
}])
probability = pipeline.predict_proba(patient)[0, 1]
prediction = "Diabetes" if probability >= threshold else "No Diabetes"
print(prediction, probability)
Pregnancies, Glucose, BloodPressure, SkinThickness,
Insulin, BMI, DiabetesPedigreeFunction, Age.Glucose, BloodPressure, SkinThickness, Insulin, and BMI use
0 to encode missing values in the source data; these are treated as
missing and median-imputed (fit on the training split only).random_state=42.A 5-fold cross-validated grid search (training set only, scored by
ROC-AUC) compared 3 model families, each with class_weight="balanced"
to address low recall on the diabetes class:
| Candidate | CV ROC-AUC | Best hyperparameters |
|---|---|---|
| logistic_regression | 0.845 | {'classifier__C': 0.1} |
| random_forest | 0.8386 | {'classifier__max_depth': 5, 'classifier__min_samples_leaf': 1, 'classifier__n_estimators': 200} |
| hist_gradient_boosting | 0.829 | {'classifier__learning_rate': 0.03, 'classifier__max_depth': 3, 'classifier__max_iter': 100} |
The decision threshold (0.58) was then chosen from out-of-fold predictions to maximize F1, instead of leaving it at the default 0.5.
Test set (n=154, threshold=0.58):
| Metric | Value |
|---|---|
| Accuracy | 0.7208 |
| Precision | 0.6 |
| Recall | 0.6111 |
| F1 | 0.6055 |
| ROC-AUC | 0.8104 |
5-fold cross-validation (training set, mean ± std):
| Metric | Score |
|---|---|
| accuracy | 0.7671 ± 0.0081 |
| precision | 0.6515 ± 0.0203 |
| recall | 0.7198 ± 0.05 |
| f1 | 0.6823 ± 0.0168 |
| roc_auc | 0.845 ± 0.013 |
Sanity checks: model ROC-AUC 0.8104 vs. a class-balance-only baseline of 0.5452. Bootstrap 95% CI for test-set ROC-AUC: [0.7321, 0.8759] (2000 resamples) — a reminder that a single 154-patient test set carries real uncertainty.
Diabetes risk prediction is sensitive: false negatives could delay appropriate care, and false positives could cause unnecessary worry. Real-world use would require clinical validation, regulatory review, and ongoing monitoring — well beyond the scope of this prototype.
RavshanjonEminov/diabetes-risk-prediction).