medical-data-visualizer/medical_data_visualizer.py
Ilenia 988c0755a1
Fix/test and missing definition (#18)
* added missing comment on setting up matplotlib

* changed assertion description so that it makes sense

* fig definition

* new comment
2022-07-25 23:11:06 +02:00

61 lines
1.3 KiB
Python

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
# Import data
df = None
# Add 'overweight' column
df['overweight'] = None
# Normalize data by making 0 always good and 1 always bad. If the value of 'cholesterol' or 'gluc' is 1, make the value 0. If the value is more than 1, make the value 1.
# Draw Categorical Plot
def draw_cat_plot():
# Create DataFrame for cat plot using `pd.melt` using just the values from 'cholesterol', 'gluc', 'smoke', 'alco', 'active', and 'overweight'.
df_cat = None
# Group and reformat the data to split it by 'cardio'. Show the counts of each feature. You will have to rename one of the columns for the catplot to work correctly.
df_cat = None
# Draw the catplot with 'sns.catplot()'
# Get the figure for the output
fig = None
# Do not modify the next two lines
fig.savefig('catplot.png')
return fig
# Draw Heat Map
def draw_heat_map():
# Clean the data
df_heat = None
# Calculate the correlation matrix
corr = None
# Generate a mask for the upper triangle
mask = None
# Set up the matplotlib figure
fig, ax = None
# Draw the heatmap with 'sns.heatmap()'
# Do not modify the next two lines
fig.savefig('heatmap.png')
return fig