This application uses k-Nearest Neighbors (k-NN) and Naive Bayes models to predict whether a person has diabetes based on various health parameters. The user can interact with the application via a graphical user interface (GUI) built using PyQt5.
diabetes.csv
: The dataset containing health parameters and diabetes outcomes.diabetes_model_knn.pkl
: The trained k-Nearest Neighbors model.diabetes_model_nb.pkl
: The trained Naive Bayes model.diabetes_prediction.py
: The main Python script that loads the models, reads the data, and runs the PyQt5 GUI for making predictions.
- Python 3.x
pip
(Python package installer)
Install the required packages using the following command:
pip install -r requirements.txt
- pandas
- joblib
- scikit-learn
- PyQt5
If you need to retrain the models, use the following scripts:
Train k-Nearest Neighbors Model
python knn.py
Train gausian Naive Bayes Model
python gausian_naive_bayes.py
-
Ensure the dataset and models are available:
Place the following files in the same directory as diabetes_prediction.py:
- diabetes.csv
- diabetes_model_knn.pkl
- diabetes_model_nb.pkl
-
Run the application:
Execute the main script using Python:
python DiabetesPredictionApp.py
-
The application window will open. You can input your medical information into the fields provided.
-
Click on the "Predict" button to get the prediction result.
-
You can also click on the "Load Random Data" button to load a random sample from the dataset for testing.
The main application is defined in app.py
. It includes:
- Model Loading: The
loadModel
method loads the kNN model and the dataset. - UI Initialization: The
initUI
method sets up the user interface including input fields, labels, and buttons. - Event Handling: The
loadRandomData
andpredictDiabetes
methods handle the button click events to load data and make predictions, respectively.
- addQLabel: Creates and returns a
QLabel
with the specified text and styles. - addQLineEdit: Creates and returns a
QLineEdit
with a validator for user input.
Feel free to submit issues and enhancement requests.
This project is licensed under the MIT License. See the LICENSE
file for details.
The dataset used for training the models is sourced from the PIMA Indians Diabetes Database. Thanks to the developers of the Python packages used in this project: Pandas, scikit-learn, joblib, and PyQt5.