0
0
ML Pythonprogramming~20 mins

Correlation analysis in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Correlation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Pearson Correlation Coefficient

Which statement correctly describes the Pearson correlation coefficient between two variables?

AIt measures the difference in means between two groups.
BIt measures the probability that two variables are independent.
CIt measures the strength and direction of a linear relationship between two continuous variables.
DIt measures the total variance explained by a regression model.
Attempts:
2 left
Predict Output
intermediate
2:00remaining
Output of Correlation Calculation in Python

What is the output of the following Python code?

ML Python
import numpy as np
x = np.array([1, 2, 3, 4, 5])
y = np.array([2, 4, 6, 8, 10])
correlation = np.corrcoef(x, y)[0, 1]
print(round(correlation, 2))
A-1.00
B0.80
C0.00
D1.00
Attempts:
2 left
Model Choice
advanced
2:00remaining
Choosing Correlation Method for Nonlinear Data

You have two variables with a clear nonlinear but monotonic relationship. Which correlation method is best to measure their association?

ASpearman rank correlation coefficient
BChi-square test
CMean squared error
DPearson correlation coefficient
Attempts:
2 left
Metrics
advanced
2:00remaining
Interpreting Correlation Matrix Output

Given the correlation matrix below, how many pairs of variables have a strong positive correlation (above 0.7)?

   A    B    C    D
A  1.0  0.8  0.3  0.6
B  0.8  1.0  0.5  0.9
C  0.3  0.5  1.0  0.2
D  0.6  0.9  0.2  1.0
A3
B2
C4
D1
Attempts:
2 left
🔧 Debug
expert
2:00remaining
Debugging Correlation Calculation Code

What error does the following Python code raise?

import numpy as np
x = [1, 2, 3]
y = [4, 5]
correlation = np.corrcoef(x, y)[0, 1]
print(correlation)
AValueError due to different lengths of x and y
BIndexError due to accessing [0, 1] in a 1D array
CTypeError because lists cannot be used with np.corrcoef
DNo error, prints correlation value
Attempts:
2 left