The Medical Data Visualizer project is part of the Data Analysis with Python certification from freeCodeCamp. This project involves visualizing a medical dataset to explore various relationships and trends between factors like cholesterol, glucose levels, smoking habits, and more, using Python libraries such as Pandas, Seaborn, and Matplotlib.
The goal of this project is to load, clean, and analyze the data to create meaningful visualizations that can provide insights into cardiovascular health. The project includes two main visualizations:
- A Categorical Plot that shows the distribution of certain features (like cholesterol, glucose levels, smoking habits, etc.) based on the presence or absence of cardiovascular disease.
- A Heatmap that visualizes the correlation between different features of the dataset.
pandas: For data manipulation and analysisseaborn: For data visualizationmatplotlib: For additional plotting functionalitynumpy: For numerical operations
The dataset undergoes several cleaning steps to ensure that the data is suitable for analysis:
- Overweight Calculation: A new column
overweightis added based on the BMI formula. - Normalization of Cholesterol and Glucose Levels: Cholesterol and glucose columns are simplified to binary values (1 or 0).
- Removal of Invalid Entries: Certain rows are filtered based on valid values for attributes like blood pressure, height, and weight.
-
Categorical Plot: This plot visualizes the distribution of key variables (
cholesterol,gluc,smoke,alco,active, andoverweight) based on the presence or absence of cardiovascular disease.- The
sns.catplotfunction is used to create a bar plot that shows the counts of each variable grouped bycardio(presence of cardiovascular disease).
- The
-
Heatmap: This heatmap visualizes the correlation matrix of the dataset, showing how different medical variables relate to each other.
- The
sns.heatmapfunction is used to generate a heatmap of the correlation coefficients.
- The
This function generates and saves a categorical plot (catplot.png) to visualize the distribution of key features based on the presence of cardiovascular disease.
This function generates and saves a heatmap (heatmap.png) to visualize correlations between different medical attributes in the dataset.