Skip to content

Conversation

@AishVerse
Copy link

🧩 Heart Disease Risk Analysis and Visualization β€” Python Project

πŸ”— Related Issue

Closes #912


πŸ“ Description

This pull request adds a Python project that performs heart disease risk analysis using simulated patient data.
The script calculates a Risk Score for each patient and visualizes important insights using matplotlib charts.


βš™οΈ Features Implemented

  • Generates synthetic patient dataset using numpy and pandas
  • Calculates health metrics:
    • Average Cholesterol
    • Average Resting BP
    • Average Heart Rate
  • Categorizes patients by age groups (Young, Middle, Old)
  • Computes a Risk Score based on weighted health parameters
  • Displays top 5 high-risk patients
  • Generates three visualizations:
    • πŸ“Š Age distribution histogram
    • πŸ“ˆ Chest pain type frequency bar chart
    • πŸ₯§ Disease ratio pie chart

πŸ’» Code Overview

File: finalproj.py

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Generate synthetic data
np.random.seed(111)
data = {
    'Age': np.random.randint(29, 77, 300),
    'Cholesterol': np.random.randint(150, 300, 300),
    'RestingBP': np.random.randint(90, 180, 300),
    'MaxHeartRate': np.random.randint(70, 190, 300),
    'ChestPainType': np.random.choice(['Typical', 'Atypical', 'Non-Anginal', 'Asymptomatic'], 300),
    'Disease': np.random.choice([0, 1], 300, p=[0.45, 0.55])
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Heart Disease Risk Analysis and Visualization Project in Python

1 participant