Skip to content

A fuzzy logic-based system for diagnosing heart disease risk, offering interpretable insights to support early detection and decision-making β€οΈβ€πŸ©Ή

Notifications You must be signed in to change notification settings

Amirbehnam1009/Heart-Disease-Detector-System

Repository files navigation

❀️ Diagnosis Heart Disease using Fuzzy Logic

Python Flask License Contributions

A fuzzy logic-based system for heart disease diagnosis, developed under the supervision of Prof. Mohammad Mehdi Ebadzadeh in Spring 2022.


πŸ“‹ Table of Contents


🌟 Introduction

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.


πŸ” Fuzzy Logic Process

1. 🎯 Fuzzification

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

2. πŸ€– Inference

The inference engine evaluates fuzzified inputs against a rule base (e.g., IF age is old AND cholesterol is high THEN risk is high).

3. πŸ“Š Defuzzification

Converts fuzzy outputs back to crisp values using the centroid (center of mass) method.


✨ Features

  • πŸ–₯️ 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

πŸš€ Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)

Step-by-Step Setup

1. Clone the repository

git clone https://github.com/Amirbehnam1009/Heart-Disease-Detector-System.git
cd Heart-Disease-Detector-System

2. Create a virtual environment (recommended)

python -m venv venv
source venv/bin/activate   # On Windows: venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt

πŸ’» Usage

1. Start the application

python app.py

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

πŸ“ Project Structure

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 documentation

πŸ“„ License

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

πŸ“Έ Simulation Results

Input Interface Fuzzy1

Output Result Fuzzy2

About

A fuzzy logic-based system for diagnosing heart disease risk, offering interpretable insights to support early detection and decision-making β€οΈβ€πŸ©Ή

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published