Heart Disease Detection Naive Bayes
No description available
๐ ๏ธ Technologies Used
HTML
Python
Python
scikit-learn
pandas
Flask
HTML
NumPy
# Heart-disease-detection-naive-bayesian
๐ Project Overview
Heart disease is one of the leading causes of death worldwide. Early prediction and diagnosis can significantly reduce mortality rates and improve patient outcomes. This project focuses on the design and implementation of a Heart Disease Prediction System using the Naive Bayes algorithm.
The system analyzes patient health parameters and predicts whether a person is likely to have heart disease. It provides both command-line and web-based interfaces, making it easy to use for healthcare applications.
๐ฏ Objectives
To predict heart disease using machine learning techniques
To implement the Naive Bayes classifier for medical data analysis
To develop a user-friendly web interface for prediction
To assist doctors and patients in early diagnosis
To achieve reliable prediction accuracy with minimal computational cost
๐ง Technology Stack
Programming Language: Python
Machine Learning Algorithm: Naive Bayes (GaussianNB)
Web Framework: Flask
Libraries Used:
pandas
numpy
scikit-learn
flask
Frontend: HTML, CSS
Dataset: Heart disease medical dataset
โ๏ธ System Architecture
The system consists of the following modules:
Data Generation Module
Model Training Module
Prediction Module (CLI & Web)
Web Interface Module
Visualization Module (Histogram / Graphs)
๐ Project Structure
Heart-Disease-Prediction/
โ
โโโ data/
โ โโโ heart_disease_data.csv
โ
โโโ src/
โ โโโ app.py
โ โโโ train_model.py
โ โโโ predict.py
โ โโโ generate_data.py
โ โโโ heart_disease_model.pkl
โ
โโโ templates/
โ โโโ result.html
โ
โโโ static/
โ โโโ styles.css
โ
โโโ verify_histogram.py
โโโ requirements.txt
โโโ README.md
๐งช Methodology
Data Collection
Medical data containing patient health attributes is collected.
Data Preprocessing
Data is cleaned and prepared for training.
Model Training
A Gaussian Naive Bayes classifier is trained using Scikit-learn.
Prediction
The trained model predicts the likelihood of heart disease.
Result Visualization
Prediction confidence and population comparison are displayed graphically.
โถ๏ธ How to Run the Project
1๏ธโฃ Install Dependencies
pip install -r requirements.txt
2๏ธโฃ Generate Dataset (Optional)
python src/generate_data.py
This creates:
data/heart_disease_data.csv
3๏ธโฃ Train the Model
python src/train_model.py
Trains the Naive Bayes model
Displays accuracy
Saves the model as:
src/heart_disease_model.pkl
4๏ธโฃ Run Prediction (Command Line)
python src/predict.py
Enter patient details when prompted
Get heart disease prediction instantly
5๏ธโฃ Run Web Application
python src/app.py
Open browser and visit:
http://127.0.0.1:5000
Enter health parameters
View prediction result
See confidence percentage and histogram
๐ Output Screens
Prediction Result Page
Likely Heart Disease / No Heart Disease
Confidence Percentage
Population Comparison Graph
โ
Advantages
Simple and efficient algorithm
High prediction accuracy
Low computational complexity
User-friendly interface
Suitable for real-time healthcare applications
โ ๏ธ Limitations
Depends on quality of dataset
Assumes independence between features
Performance may vary with unseen data
๐ Future Enhancements
Integration with real-time hospital databases
Use of hybrid machine learning models
Mobile application support
Cloud-based deployment
Integration with wearable health devices
๐ Conclusion
This project successfully demonstrates the application of Naive Bayes classification in predicting heart disease. The system provides an effective decision-support tool for early diagnosis and healthcare assistance. With further enhancements, it can be deployed in real-world medical environments.
๐ฉโ๐ป Developed By
Design and Implementing Heart Disease Prediction Using Naive Bayesian
Major Project โ Artificial Intelligence and Machine Learning