An advanced AI-powered diabetes risk assessment tool built with Streamlit and machine learning. This application uses sophisticated data preprocessing and multiple trained models to predict diabetes risk with high accuracy.
- Intelligent model fallback system for maximum reliability
- StandardScaler preprocessing for optimal accuracy
- Real-time confidence scoring
- Beautiful gradient-based interface with custom CSS
- Responsive design that works on all devices
- Interactive animations and visual feedback
- Real-time risk assessment indicators
- Professional medical theme with intuitive icons
- Interactive probability visualization with Plotly
- Health profile radar charts comparing user vs normal ranges
- Real-time risk factor identification
- Detailed confidence metrics and recommendations
- Intelligent error handling for model compatibility issues
- Support for multiple scikit-learn versions
- Automatic fallback model creation if needed
- Comprehensive input validation and preprocessing
- Professional logging and user feedback
- Python 3.10 or higher
- pip package manager
git clone <your-repository-url>
cd M3_Final# Create virtual environment
python -m venv kaggleenv
# Activate virtual environment
# On macOS/Linux:
source kaggleenv/bin/activate
# On Windows:
kaggleenv\Scripts\activatepip install -r requirements.txtstreamlit run diabetes_predictor_app.pyThe application will automatically open in your default browser at:
http://localhost:8501
M3_Final/
βββ π± diabetes_predictor_app.py # Main Streamlit application
βββ π 01_data_cleaning.ipynb # Data preprocessing notebook
βββ π€ 02_train_model.ipynb # Model training notebook
βββ π diabetes.csv # Original dataset
βββ β¨ diabetes_cleaned.csv # Preprocessed dataset
βββ π¦ requirements.txt # Python dependencies
βββ ποΈ model/ # Trained models directory
β βββ diabetes_model.pkl # Main trained model
β βββ diabetes_model_quick_tuned.pkl # Quick-tuned variant
β βββ diabetes_model_FAST_recall.pkl # Recall-optimized model
β βββ scaler.pkl # StandardScaler for preprocessing
βββ π kaggleenv/ # Virtual environment
βββ π README.md # This file
- StandardScaler normalization for all numerical features
- Missing value handling with median imputation
- Outlier detection and treatment using IQR method
- Feature engineering for optimal model performance
- Random Forest Classifier as primary model
- Hyperparameter tuning using GridSearchCV
- Cross-validation for robust performance evaluation
- Multiple model variants for different optimization goals
Pregnancies- Number of pregnanciesGlucose- Plasma glucose concentration (mg/dL)BloodPressure- Diastolic blood pressure (mm Hg)SkinThickness- Triceps skin fold thickness (mm)Insulin- 2-Hour serum insulin (ΞΌU/mL)BMI- Body mass index (kg/mΒ²)DiabetesPedigreeFunction- Genetic predisposition scoreAge- Age in years
- Modern gradient design with Inter font family
- Responsive layouts using Streamlit columns
- Custom animations (pulse, bounce effects)
- Interactive components with real-time feedback
- Professional medical styling with appropriate color schemes
- Model loading with error handling for compatibility issues
- Intelligent fallback system creating dummy models if needed
- Real-time risk assessment with immediate visual feedback
- Data validation ensuring realistic input ranges
- Comprehensive error reporting with user-friendly messages
- Plotly integration for interactive charts
- Real-time probability bars showing prediction confidence
- Radar charts comparing user profile vs normal ranges
- Risk indicator system with color-coded warnings
- Professional medical chart styling
| Metric | Score |
|---|---|
| Accuracy | ~81-85% |
| Precision | ~80-84% |
| Recall | ~75-85% |
| F1-Score | ~78-82% |
| AUC-ROC | ~0.85-0.90 |
- Enter patient information in the input form
- Review real-time risk indicators as you type
- Click "PREDICT DIABETES RISK" for AI analysis
- Review detailed results including confidence scores
- Analyze visualizations for comprehensive understanding
- All fields are required for accurate prediction
- Use realistic medical values for best results
- Refer to normal ranges shown in tooltips
- The app handles data normalization automatically
- π¨ High Risk: Immediate medical consultation recommended
β οΈ Medium Risk: Regular monitoring and lifestyle changes- β Low Risk: Continue healthy habits and routine checkups
- Train your model using the provided notebooks
- Save as
.pklfile in themodel/directory - Update the model loading logic in
diabetes_predictor_app.py
- Modify CSS in the
st.markdown()sections - Update color schemes in the gradient definitions
- Add new components using Streamlit's component library
- Add new health indicators in
FEATURE_INFO - Implement additional visualization types
- Enhance risk assessment algorithms
streamlit==1.28.0
pandas==2.0.3
numpy==1.26.4
scikit-learn==1.6.1
joblib==1.3.2
plotly==5.15.0
jupyter
kagglehub
pydeck
pillow
π§ Technical Note: The application includes intelligent compatibility handling for different scikit-learn versions and will create fallback models if needed.
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Pima Indians Diabetes Database for the training dataset
- Streamlit team for the excellent web framework
- Scikit-learn contributors for the machine learning tools
- Plotly team for the visualization library
If you encounter any issues or have questions:
- Check the error messages - the app provides detailed troubleshooting
- Verify your Python version and dependencies
- Ensure all model files are present in the
model/directory - Check scikit-learn compatibility if you see model loading errors
π©Ί Diabetes Predictor AI | Powered by Machine Learning & Advanced Data Processing
Built with β€οΈ for better healthcare screening