curriculum/challenges/english/blocks/data-analysis-with-python-projects/5e46f7f8ac417301a38fb92a.md
You will be <a href="https://app.ona.com/?autostart=true#https://github.com/freeCodeCamp/boilerplate-medical-data-visualizer/" target="_blank" rel="noopener noreferrer nofollow">working on this project with our Ona starter code</a>.
We are still developing the interactive instructional part of the Python curriculum. For now, here are some videos on the freeCodeCamp.org YouTube channel that will teach you everything you need to know to complete this project:
<a href="https://www.freecodecamp.org/news/python-for-everybody/" target="_blank" rel="noopener noreferrer nofollow">Python for Everybody Video Course</a> (14 hours)
<a href="https://www.freecodecamp.org/news/how-to-analyze-data-with-python-pandas/" target="_blank" rel="noopener noreferrer nofollow">How to Analyze Data with Python Pandas</a> (10 hours)
In this project, you will visualize and make calculations from medical examination data using matplotlib, seaborn, and pandas. The dataset values were collected during medical examinations.
The rows in the dataset represent patients and the columns represent information like body measurements, results from various blood tests, and lifestyle choices. You will use the dataset to explore the relationship between cardiac disease, body measurements, blood markers, and lifestyle choices.
File name: medical_examination.csv
| Feature | Variable Type | Variable | Value Type |
|---|---|---|---|
| Age | Objective Feature | age | int (days) |
| Height | Objective Feature | height | int (cm) |
| Weight | Objective Feature | weight | float (kg) |
| Gender | Objective Feature | gender | categorical code |
| Systolic blood pressure | Examination Feature | ap_hi | int |
| Diastolic blood pressure | Examination Feature | ap_lo | int |
| Cholesterol | Examination Feature | cholesterol | 1: normal, 2: above normal, 3: well above normal |
| Glucose | Examination Feature | gluc | 1: normal, 2: above normal, 3: well above normal |
| Smoking | Subjective Feature | smoke | binary |
| Alcohol intake | Subjective Feature | alco | binary |
| Physical activity | Subjective Feature | active | binary |
| Presence or absence of cardiovascular disease | Target Variable | cardio | binary |
Create a chart similar to examples/Figure_1.png, where we show the counts of good and bad outcomes for the cholesterol, gluc, alco, active, and smoke variables for patients with cardio=1 and cardio=0 in different panels.
By each number in the medical_data_visualizer.py file, add the code from the associated instruction number below.
medical_examination.csv and assign it to the df variable.overweight column to the data. To determine if a person is overweight, first calculate their BMI by dividing their weight in kilograms by the square of their height in meters. If that value is > 25 then the person is overweight. Use the value 0 for NOT overweight and the value 1 for overweight.0 always good and 1 always bad. If the value of cholesterol or gluc is 1, set the value to 0. If the value is more than 1, set the value to 1.draw_cat_plot function.pd.melt with values from cholesterol, gluc, smoke, alco, active, and overweight in the df_cat variable.df_cat 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.long format and create a chart that shows the value counts of the categorical features using the following method provided by the seaborn library import: sns.catplot().fig variable.draw_heat_map function.df_heat variable by filtering out the following patient segments that represent incorrect data:
(df['ap_lo'] <= df['ap_hi']))(df['height'] >= df['height'].quantile(0.025)))corr variable.mask variable.matplotlib figure.seaborn library import: sns.heatmap().Write your code in medical_data_visualizer.py. For development, you can use main.py to test your code.
The unit tests for this project are in test_module.py. We imported the tests from test_module.py to main.py for your convenience.
Copy your project's URL and submit it to freeCodeCamp.
It should pass all Python tests.
# Python challenges don't need solutions,
# because they would need to be tested against a full working project.
# Please check our contributing guidelines to learn more.