Tutorial_02_Tasks
August 1, 2018
QBUS6850 – Machine Learning for Business
Task 1 – Matrices and Vectors
1. Create two vectors a = [1, 2, 0]T and b = [2,−1, 10]T
2. Calculate c = aTb i.e. the inner product of a and b
3. Are a and b orthogonal?
4. Create a matrix A =
[
1 −1 2
0 −3 1
]
5. Calculate x = Ab
6. What is the size (shape) of x?
7. Calculate Y = ATA
8. What is the size (shape) of Y?
Task 2 – Pandas
Download the happiness_2016.csv file from blackboard.
This file contains the data from the world happiness report and contains a number of metrics
about each country relating to quality of life.
1. Load the happiness_2016.csv data file using Pandas read_csv
2. Check if there are any missing or corrupt values by using
In [ ]: print(“Contains missing values”) if happiness_df.isnull().values.any() else print(“No missing values”)
3. Delete rows containing NaN values
4. Get all countries in South East Asia with a Freedom score greater than 0.5 (store in variable
called ’free_sea’)
Task 3 – Plotting
1. Plot a bar chart of ’free_sea’. Include:
• Labels for each bar
• X axis label
• Y axis label
• Title
1
2. Plot a line chart of ’Health (Life Expectancy)’ of all countries in descending order (left to
right). Include:
• X axis label
• Y axis label
• Title
• Legend
2