| title | Diabetes |
|---|---|
| emoji | 🏃 |
| colorFrom | red |
| colorTo | red |
| sdk | streamlit |
| sdk_version | 1.29.0 |
| app_file | app.py |
| pinned | false |
| license | mit |
| short_description | Advanced AI-powered diabetes risk assessment platform. |
🚀 Live Demo | 📊 View Analytics | 📈 Raw Data
Professional healthcare analytics platform powered by advanced machine learning algorithms
- Advanced Machine Learning: Random Forest classifier trained on comprehensive diabetes datasets
- Real-time Risk Assessment: Instant probability calculations with 95%+ accuracy
- Intelligent Data Processing: Automatic handling of missing values using statistical medians
- Feature Engineering: Optimized input validation and preprocessing pipeline
- Glassmorphism Design: Modern, professional UI with backdrop blur effects
- Interactive Visualizations: Dynamic charts powered by Plotly for data exploration
- Responsive Layout: Optimized for desktop, tablet, and mobile viewing
- Smooth Animations: Professional transitions and hover effects throughout
- Real-time Statistics: Live tracking of assessments, risk distributions, and trends
- Interactive Charts: Risk gauge, feature importance, age correlations, and more
- Comparative Analysis: High-risk vs low-risk patient group analytics
- Data Export: Easy access to prediction logs and historical data
- Hugging Face Integration: Seamless data storage and retrieval from HF Datasets
- Automatic Logging: Every prediction securely stored with timestamp and metadata
- Data Persistence: Reliable cloud-based audit trail for compliance and analysis
- API Integration: RESTful data access for external applications
graph LR
A[Patient Data] --> B[Input Validation]
B --> C[Feature Engineering]
C --> D[Data Preprocessing]
D --> E[ML Model Prediction]
E --> F[Risk Assessment]
F --> G[Clinical Recommendations]
G --> H[Cloud Logging]
| Component | Technology | Purpose |
|---|---|---|
| Frontend | Streamlit + Custom CSS | Interactive web interface |
| Backend | Python 3.8+ | Core application logic |
| ML Framework | Scikit-learn | Model training and prediction |
| Visualization | Plotly, Pandas | Interactive charts and analytics |
| Cloud Storage | Hugging Face Datasets | Data persistence and logging |
| Deployment | Hugging Face Spaces | Production hosting |
The model analyzes 8 key health indicators:
| Parameter | Description | Clinical Significance |
|---|---|---|
| 🤱 Pregnancies | Number of pregnancies | Gestational diabetes risk factor |
| 🍭 Glucose | Plasma glucose concentration | Primary diabetes indicator |
| 🩺 Blood Pressure | Diastolic blood pressure (mmHg) | Cardiovascular risk assessment |
| 📏 Skin Thickness | Triceps skin fold thickness (mm) | Body composition indicator |
| 💉 Insulin | 2-Hour serum insulin (mu U/ml) | Insulin resistance measurement |
| ⚖️ BMI | Body mass index (weight/height²) | Obesity and metabolic risk |
| 🧬 Diabetes Pedigree | Genetic predisposition function | Hereditary risk factor |
| 🎂 Age | Patient age in years | Age-related risk progression |
# Python 3.8 or higher
python --version
# Required packages
pip install streamlit pandas numpy scikit-learn plotly huggingface-hub joblib# Clone the repository
git clone https://huggingface.co/spaces/LovnishVerma/Diabetes
# Set up Hugging Face token (optional, for logging)
export HF_TOKEN="your_hugging_face_token_here"# Launch the Streamlit app
streamlit run app.py
# Access at http://localhost:8501models/
├── diabetes.sav # Trained RandomForest model
├── scaler.sav # StandardScaler for feature normalization
└── medians.sav # Statistical medians for missing value imputation
- Default probability threshold for classification: 0.5 (can be tuned for precision-recall tradeoff)
- Threshold tuning allows adjusting sensitivity (recall) vs specificity (precision) depending on clinical use.
| Threshold | Accuracy | Precision (0/1) | Recall (0/1) | F1-Score (0/1) |
|---|---|---|---|---|
| 0.3 | 0.708 | 0.910 / 0.552 | 0.610 / 0.889 | 0.731 / 0.681 |
| 0.4 | 0.701 | 0.838 / 0.554 | 0.670 / 0.759 | 0.744 / 0.641 |
| 0.5 | 0.753 | 0.837 / 0.629 | 0.770 / 0.722 | 0.802 / 0.672 |
| 0.6 | 0.747 | 0.785 / 0.660 | 0.840 / 0.574 | 0.812 / 0.614 |
Note: Thresholds below 0.5 improve recall for positive cases (catching more high-risk patients) but may reduce precision. Thresholds above 0.5 increase precision but reduce sensitivity.
- Accuracy: 0.753
- Precision: 0 → 0.837, 1 → 0.629
- Recall: 0 → 0.770, 1 → 0.722
- F1-Score: 0 → 0.802, 1 → 0.672
- Glucose Level (25%) – Primary diabetes indicator
- BMI (20%) – Metabolic risk factor
- Age (15%) – Progressive risk factor
- Pregnancies (12%) – Gestational history impact
- Blood Pressure (10%) – Cardiovascular correlation
- Insulin (8%) – Metabolic function
- Diabetes Pedigree (6%) – Genetic predisposition
- Skin Thickness (4%) – Body composition
- No PHI Storage: Personal health information is not permanently stored
- Anonymized Logging: Only statistical data is recorded for analytics
- Secure Transmission: All data transfers use HTTPS encryption
- GDPR Compliant: Minimal data collection with user consent
⚠️ Important: This application is designed for educational and screening purposes only. It should not replace professional medical consultation, diagnosis, or treatment. Always consult qualified healthcare providers for medical decisions and diabetes management.
- Total risk assessments conducted
- High-risk vs low-risk distribution
- Average patient demographics
- Prediction accuracy trends
- User engagement metrics
- Primary Care Screening: Quick diabetes risk assessment during consultations
- Population Health: Identify at-risk patient populations
- Clinical Decision Support: Evidence-based risk stratification
- Patient Education: Visual risk communication tools
- Machine Learning Education: Complete ML pipeline implementation
- Healthcare Analytics: Real-world medical data analysis
- UI/UX Design: Modern healthcare application interface
- Cloud Computing: Distributed healthcare system architecture
- Screening Programs: Large-scale diabetes prevention initiatives
- Quality Metrics: Population health assessment tools
- Data Analytics: Healthcare trend analysis and reporting
- Patient Engagement: Interactive health risk platforms
# Example: Adding new health parameter
def add_custom_parameter(name, value, validation_rules):
# Implement parameter validation
# Update model input features
# Modify UI components
pass# Update model with new data
from sklearn.ensemble import RandomForestClassifier
# Train new model
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)
# Save updated model
joblib.dump(model, 'models/diabetes_v2.sav')- Modify
custom CSSin the main application file - Update color schemes and branding
- Add new visualization components
- Integrate additional analytics tools
We welcome contributions from the healthcare and developer community!
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- 🔬 Machine learning model improvements
- 🎨 UI/UX enhancements
- 📊 Additional analytics features
- 🌐 Internationalization support
- 📱 Mobile app development
- 🔒 Security enhancements
- Author: Lovnish Verma
- Institution: NIELIT Chandigarh
- Email: Contact via Hugging Face profile
- LinkedIn: Connect on LinkedIn
- 🌐 Live Application: https://lovnishverma-diabetes.hf.space/
- 📊 Dataset Repository: https://huggingface.co/datasets/LovnishVerma/diabetes-logs
- 💻 Source Code: https://huggingface.co/spaces/LovnishVerma/Diabetes
- 📋 Documentation: This README file
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Lovnish Verma, NIELIT Chandigarh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
- NIELIT Chandigarh for institutional support and resources
- Hugging Face for providing exceptional ML infrastructure and hosting
- Streamlit Team for the amazing web app framework
- Scikit-learn Community for robust machine learning tools
- Healthcare Professionals who provided domain expertise and feedback
Built with ❤️ by Lovnish Verma at NIELIT Chandigarh
