This Diabetes Prediction App is built using Streamlit to predict whether a person is likely to develop diabetes based on their health parameters. The app takes various inputs, such as pregnancies, glucose levels, blood pressure, BMI, and more, and uses a pre-trained machine learning model to provide a prediction.
- User-friendly interface: Input fields are neatly organized into two columns for better readability.
- Interactive prediction: Users can input values and receive a prediction by clicking the "Predict" button.
- Custom styling: The app uses custom CSS for a clean and modern look.
- Diabetes Prediction Model: The app leverages a pre-trained ensemble model (loaded from a file) to make predictions based on input parameters.
Before running the application, ensure you have the following:
- Python 3.x installed.
- Necessary dependencies installed from
requirements.txt
.
Make sure your project has the following structure:
project_root/
│
├── model/
│ ├── scaler.pkl
│ └── ensemble_model.pkl
│
├── app.py
├── requirements.txt
scaler.pkl
: The scaler used for normalizing input data.ensemble_model.pkl
: The trained ensemble model for diabetes prediction.app.py
: The main script that runs the Streamlit app.requirements.txt
: The file containing the necessary Python libraries.
To install the required dependencies, run the following command in your project directory:
pip install -r requirements.txt
Once dependencies are installed, you can run the app by executing the following command in the terminal:
streamlit run app.py
The app will open in your browser, and you can input health parameters to predict the likelihood of diabetes.
- Loading Models: The app loads the pre-trained scaler and ensemble model from the
model/
directory using Joblib. - User Input: The app collects the following user inputs:
- Pregnancies
- Glucose
- Blood Pressure
- BMI
- Skin Thickness
- Insulin
- Diabetes Pedigree Function
- Age
- Scaling Input Data: The inputs are scaled using the loaded
scaler.pkl
model. - Prediction: The scaled data is passed to the loaded
ensemble_model.pkl
, which predicts whether the person is likely to have diabetes (binary output: 0 or 1). - Displaying Results: Based on the prediction, the app displays:
- An error message if the prediction is positive (likely to have diabetes).
- A success message if the prediction is negative (unlikely to have diabetes).