Coder Social home page Coder Social logo

diabetes-prediction's Introduction

Diabetes Prediction Application using ML Models

Diabetes Prediction

Overview

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.

Project Files

  • 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.

Installation

Prerequisites

  • Python 3.x
  • pip (Python package installer)

Required Python Packages

Install the required packages using the following command:

pip install -r requirements.txt

requirements.txt should contain:

  • pandas
  • joblib
  • scikit-learn
  • PyQt5

Model Training

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

Usage

  1. 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
  2. Run the application:

    Execute the main script using Python:

    python DiabetesPredictionApp.py
  3. The application window will open. You can input your medical information into the fields provided.

  4. Click on the "Predict" button to get the prediction result.

  5. You can also click on the "Load Random Data" button to load a random sample from the dataset for testing.

Code Overview

Main Application

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 and predictDiabetes methods handle the button click events to load data and make predictions, respectively.

Helper Functions

  • addQLabel: Creates and returns a QLabel with the specified text and styles.
  • addQLineEdit: Creates and returns a QLineEdit with a validator for user input.

Contributing

Feel free to submit issues and enhancement requests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

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.

diabetes-prediction's People

Contributors

redoy-ahmed avatar redoycel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.