Challenge - 5 Problems
Correlation Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Pearson correlation calculation
What is the output of this Python code calculating Pearson correlation between two lists?
Data Analysis Python
import numpy as np from scipy.stats import pearsonr x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] correlation, p_value = pearsonr(x, y) print(round(correlation, 2))
Attempts:
2 left
💡 Hint
Pearson correlation measures linear relationship strength.
✗ Incorrect
The lists y and x have a perfect linear relationship (y = 2*x), so Pearson correlation is 1.00.
❓ data_output
intermediate2:00remaining
Spearman correlation output for rank data
Given these two lists, what is the Spearman correlation coefficient output?
Data Analysis Python
from scipy.stats import spearmanr x = [10, 20, 30, 40, 50] y = [2, 1, 3, 5, 4] correlation, _ = spearmanr(x, y) print(round(correlation, 2))
Attempts:
2 left
💡 Hint
Spearman correlation measures monotonic relationship using ranks.
✗ Incorrect
Spearman correlation here is about 0.80, reflecting moderate positive monotonic association.
🧠 Conceptual
advanced2:00remaining
Difference between Pearson and Spearman correlation
Which statement correctly describes the difference between Pearson and Spearman correlation?
Attempts:
2 left
💡 Hint
Think about how each correlation handles data ordering and linearity.
✗ Incorrect
Pearson correlation measures linear association between variables, while Spearman uses ranked data to measure monotonic relationships.
🔧 Debug
advanced2:00remaining
Identify the error in correlation calculation code
What error will this code raise when calculating Pearson correlation?
Data Analysis Python
from scipy.stats import pearsonr x = [1, 2, 3] y = [4, 5] correlation, p = pearsonr(x, y)
Attempts:
2 left
💡 Hint
Check if the input lists have the same number of elements.
✗ Incorrect
Pearson correlation requires x and y to be the same length; here they differ, causing ValueError.
🚀 Application
expert2:00remaining
Choosing correlation method for non-linear but monotonic data
You have two variables with a clear monotonic but non-linear relationship. Which correlation method should you use to best capture their association?
Attempts:
2 left
💡 Hint
Consider which method uses ranks and can detect monotonic relationships.
✗ Incorrect
Spearman correlation captures monotonic relationships even if they are not linear, unlike Pearson.