Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

SIT720 Machine Learning Assessment Task 1: Problem solving task. ©Deakin University XXXXXXXXXX1 XXXXXXXXXXSIT720 This document supplies detailed information on Assessment Task 1 for this unit. Key...

1 answer below »
SIT720 Machine Learning
Assessment Task 1: Problem solving task.

©Deakin University XXXXXXXXXX1 XXXXXXXXXXSIT720
This document supplies detailed information on Assessment Task 1 for this unit.
Key information
• Due: Monday 26 July 2021 by 8.00 pm (AEST)
• Weighting: 5%
Learning Outcomes
This assessment assesses the following Unit Learning Outcomes (ULO) and related Graduate Learning
Outcomes (GLO):
Unit Learning Outcome (ULO) Graduate Learning Outcome (GLO)
ULO1 - Perform Python programming to solve a
given problem.
GLO1 - through the assessment of student ability to
use data acquisition.
techniques to obtain, manipulate and represent data.
GLO2 - through the assessment of communicating
the results in specific format.
GLO3 - through student ability to use specific
programming language and modules to obtain, pre-
process, transform and analyse data.
Purpose
This assessment task is for student to apply Python programming skills for loading, visualising, manipulating
and exporting data using various modules and packages.

Assessment 1 XXXXXXXXXXTotal marks = 30 XXXXXXXXXX15 * 2 = 30

Submission Instructions
a) Submit your solution into a notebook file with “.ipynb” extension.
) Insert your Python code or text responses into the cell of your submitted file followed by the question i.e.,
copy the question by adding a cell before the solution cell. If you need multiple cells for better
presentation of the code or answer, add question only before the first solution cell.
c) Your submitted code should be executable. If your code does not generate the submitted solution, then
you will get zero for that part of the marks.
d) For answers regarding discussion or explanation, maximum five sentences are XXXXXXXXXXsuggested.
e) Answers must be relevant and precise.
f) No hard coding is allowed. Avoid using specific value that can be calculated from the data provided.
g) Submit your assignment after running each cell individually with the output.
h) The submitted notebook file name should be of this form “SIT720_A1_studentID.ipynb”. For example, if
your student ID is 1234, then the submitted file name should be SIT720_A1_1234.ipynb.

Background
According to World Health Organization (WHO), cardiovascular diseases (CVDs) are the number 1 cause of
death globally, taking an estimated 17.9 million lives each year and affecting the quality of life of a large
number of people worldwide. Prerequisites of the treatment of these types of disease involve proper diagnosis
method to identify its occu
ence and its type.

SIT720 Machine Learning
Assessment Task 1: Problem solving task.

©Deakin University XXXXXXXXXX2 XXXXXXXXXXSIT720
Diagnosis of such diseases always involve a large number of parameters to help the Cardiologists to identify
them. Electrocardiography (ECG) is most commonly used to observe patient's cardiac states. The following
image shows different ECG waves (P, Q, R, S, T, etc).
Fig: Electrocardiogram trace with respective biomarkers. [Image source: https:
litfl.com/wp-
content/uploads/2018/10/ECG-waves-segments-and- intervals-LITFL-ECG-li
ary-3.jpg]
In this assignment, you will have a look at such a dataset containing different parameters along with the decision
of the Cardiologists about the level of a sample heart disease. There will be a list of tasks to check your ability to
use of programming skill, basic logics, and reasoning.
Dataset
Dataset file name: A1_heart_disease_dataset.csv

Dataset description: Dataset contains different features along with the disease state. It contains total 13 features
and an additional disease state, in total 14 columns. It contains different types of data including int, float and string.
Feature names, data type and values are described in the following section with their proper unit details. Data may
contain 'null' or 'nan' values. Each observation is a datapoint along the row of the dataset. Patient and observation
are used interchangeably in this case.

Features:
i. age (int): age of the patient in year
ii. sex (str): gender of the patient (M: male, F: female)
iii. cp (str): chest pain type (tap: typical angina, aap: atypical angina, nap: non-anginal pain, asp:
asymptomatic pain)
iv. trestbps (float): resting blood pressure (in mm Hg on admission to the hospital)
v. chol (float): serum cholesterol in mg/dl
vi. fbs (bool): is fasting blood sugar higher than standard 120 mg/dl? (yes: if true; no: if false)
vii. restecg (int): resting electrocardiographic results (0: normal, 1: having ST-T wave abnormality (T
wave inversions and/or ST elevation or depression of > 0.05 mV), 2: showing probable or definite
left ventricular hypertrophy by Estes' criteria)
viii. thalach (float): maximum heart rate achieved
ix. exang (bool): exercise induced angina (true: if yes; false: if no)
x. oldpeak (float): ST interval depression induced by exercise relative to rest
%5bImage%20source:%20https:/litfl.com/wp-content/uploads/2018/10/ECG-waves-segments-and-%20intervals-LITFL-ECG-li
ary-3.jpg%5d
%5bImage%20source:%20https:/litfl.com/wp-content/uploads/2018/10/ECG-waves-segments-and-%20intervals-LITFL-ECG-li
ary-3.jpg%5d

SIT720 Machine Learning
Assessment Task 1: Problem solving task.

©Deakin University XXXXXXXXXX3 XXXXXXXXXXSIT720
xi. slope (float): the slope of the peak exercise ST segment (1: up-sloping, 2: flat, 3: down-
sloping)
xii. ca (int): number of major vessels (0-3) affected
xiii. thal (int): thalassemia state (3: normal; 6: fixed defect; 7: reversable defect)
xiv. state (int): heart disease risk state (0: no disease, 1-4: level of risk) [Decided by cardiologists]
_____________________________________________________________________________________
Questions
_____________________________________________________________________________________
1. Load the data from supplied data file. Remove the observations/samples where the heart diseases are not
diagnosed by the Cardiologists. Print the data dimension before and after removing the
observations/samples.

2. Continue from question 1. Display the number of rows and their indices that have missing data in one or
more cells. Now, replace the missing data by the lowest value of the co
esponding feature if it is a
continuous variable. In case of categorical variable, remove the sample. Print the median values of all
features before and after replacing missing data.

3. Continue from question 2. Is there any change in data type? If yes, convert them back to appropriate data
types. Print all variables with co
esponding data type.

4. Continue from question 3. Print the total numbers and ration of male and female patients who are at
highest risk of heart disease.

5. Continue from question 3. Is there any association between heart rate and severity of heart disease?
Explain your results from given dataset.

6. Continue from question 3. Print the average cholesterol level for different number of blocked blood
vessels across gender. Please report the pattern found in the result, if any.

7. Print the percentage of patients at risk of heart disease having abnormality in both ECG and blood sugar
with asymptomatic chest pain.

8. Calculate and print the average blood pressure of all observations with non-flat ST slopes of ECG.

9. Create and print a dataframe of the heart rate, blood pressure and cholesterol levels for different age
groups (based on 10 years interval).

10. Continue from question 3. Find the average cholesterol level of across gender for each age group. Please
explain the results.

11. Continue from question 3. Draw two scatter plots of cholesterol level, one against blood pressure and
another against heart rate. Draw them in two subplots of the same plot.

12. Visualize the cholesterol level against number of blood vessel blocked for male and female using line
plot. Explain the graph base on your observation.

13. Draw a group bar diagram of heart rate, blood pressure and total number of patients, based on age
groups defined in question 9. Explain your observation from the graph.


SIT720 Machine Learning
Assessment Task 1: Problem solving task
Answered 5 days After Jul 19, 2021

Solution

Atal Behari answered on Jul 24 2021
164 Votes
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## *Importing Modules*"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"import openpyxl"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## *Question no.: 1. Load the data from supplied data file. Remove the observations/samples where the heart diseases are not diagnosed by the Cardiologists. Print the data dimension before and after removing the observations/samples.*"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"text/plain": " age sex cp trestbps chol fbs restecg thalach exang oldpeak \\\n0 63.0 M tap 145.0 233.0 yes 2.0 150.0 0.0 2.3 \n1 67.0 M asp 160.0 286.0 no 2.0 108.0 1.0 1.5 \n2 67.0 M asp 120.0 229.0 no 2.0 129.0 1.0 2.6 \n3 37.0 M nap 130.0 250.0 no 0.0 187.0 0.0 3.5 \n4 41.0 F aap 130.0 204.0 no 2.0 172.0 0.0 1.4 \n5 56.0 M aap 120.0 236.0 no 0.0 178.0 0.0 0.8 \n6 62.0 F NaN 140.0 268.0 no 2.0 160.0 0.0 3.6 \n7 57.0 F asp 120.0 354.0 no 0.0 163.0 1.0 0.6 \n8 63.0 M asp 130.0 254.0 no 2.0 147.0 0.0 1.4 \n9 53.0 M asp 140.0 203.0 yes 2.0 155.0 1.0 3.1 \n\n slope ca thal state \n0 3.0 0.0 6.0 0.0 \n1 2.0 3.0 3.0 2.0 \n2 2.0 2.0 7.0 1.0 \n3 3.0 0.0 3.0 0.0 \n4 1.0 0.0 3.0 0.0 \n5 1.0 0.0 3.0 0.0 \n6 3.0 2.0 3.0 3.0 \n7 1.0 0.0 3.0 0.0 \n8 2.0 1.0 7.0 2.0 \n9 3.0 0.0 7.0 1.0 ",
"text/html": "
\n