A fuzzy logic-based system for heart disease diagnosis, developed under the supervision of Prof. Mohammad Mehdi Ebadzadeh in Spring 2022.
- Introduction
- Fuzzy Logic Process
- Features
- Installation
- Usage
- Project Structure
- License
- Simulation Results
This project implements a fuzzy logic system to assist in the diagnosis of heart disease. Unlike traditional binary systems, fuzzy logic allows for reasoning with uncertainty and imprecision, making it particularly suitable for medical diagnosis where symptoms and conditions often exist on a spectrum.
The system takes multiple medical parameters as inputs and provides a risk assessment for heart disease through a three-step fuzzy logic process: fuzzification, inference, and defuzzification.
Converts crisp input values into fuzzy values, handling uncertainties in real-world data. Membership functions determine the degree of belonging.
Input Parameters and Their Fuzzy Sets:
- πΆπ§ Age: Young, Middle-aged, Old
- π Blood Pressure: Low, Normal, High
- π§ͺ Cholesterol: Low, Medium, High
- π Heart Rate: Slow, Normal, Fast
- π ECG Results: Normal, Abnormal
- π Exercise: Sedentary, Moderate, Active
- π Diet: Poor, Average, Healthy
- π¬ Smoking: Non-smoker, Light-smoker, Heavy-smoker
- π· Alcohol: Non-drinker, Social-drinker, Heavy-drinker
- π¨βπ©βπ§βπ¦ Family History: None, Moderate, Strong
The inference engine evaluates fuzzified inputs against a rule base (e.g., IF age is old AND cholesterol is high THEN risk is high).
Converts fuzzy outputs back to crisp values using the centroid (center of mass) method.
- π₯οΈ User-friendly web interface built with Flask
- π Visual representation of fuzzy membership functions
- β‘ Real-time risk calculation
- π¨ Responsive design for multiple devices
- π Comprehensive rule base covering various risk factors
- π§ Easily extensible fuzzy system architecture
- Python 3.8 or higher
- pip (Python package manager)
1. Clone the repository
git clone https://github.com/Amirbehnam1009/Heart-Disease-Detector-System.git
cd Heart-Disease-Detector-System2. Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate3. Install dependencies
pip install -r requirements.txt1. Start the application
python app.py2.Access the web interface Open your browser and navigate to http://127.0.0.1:8448
3.Input medical parameters Adjust the sliders to match the patient's metrics:
-
Age
-
Blood Pressure
-
Cholesterol Level
-
Heart Rate
-
And other relevant factors
4.Get diagnosis results Click "Show Result" to see the fuzzy logic system's assessment of heart disease risk.
Heart-Disease-Detector-System/
β
βββ app.py # Main Flask application
βββ fuzzy_logic.py # Core fuzzy logic implementation
βββ static/ # Static files (CSS, JS, images)
β βββ css/
β βββ style.css # Styling for web interface
βββ templates/ # HTML templates
β βββ index.html # Main web page
βββ requirements.txt # Python dependencies
βββ README.md # Project documentationThis project is licensed under the MIT License - see the LICENSE file for details.