Browse and solve 1,200+ machine learning coding challenges on Deep-ML. Filter by difficulty (beginner, intermediate, advanced) and category (linear algebra, machine learning, deep learning, NLP, computer vision). Write Python solutions in the browser and get instant feedback against test cases.
Deep-ML | Compute Three Correlation Coefficients Between Score ListsCompute Three Correlation Coefficients Between Score Lists
Compute Three Correlation Coefficients Between Score Lists
Means are both 3. Pearson numerator = (-2)(-1)+(-1)(-2)+0+0+(2)(2) = 8; each denominator term is sqrt(10), so Pearson = 8/10 = 0.8. Ranks equal the values (no ties), so Spearman equals Pearson = 0.8. For Kendall, there are 10 pairs: 8 concordant and 2 discordant with no ties, giving tau-b = (8-2)/10 = 0.6.
When comparing two scoring methods (e.g., two LLM judges rating the same responses), it is common to report three correlation coefficients: Pearson, Spearman, and Kendall Tau-b. Each captures a different notion of agreement -- Pearson measures linear correlation between raw scores, Spearman measures monotonic correlation via ranks, and Kendall Tau-b measures pairwise concordance with a correction for ties.
Implement a function correlations(x, y) that takes two equal-length lists of numeric scores and returns a list of three floats [pearson, spearman, kendall_tau_b].
Spearman: the Pearson correlation computed on the ranks of x and y. Ties must be handled by assigning the average of the tied ranks (1-indexed).
Kendall Tau-b: τb=(C+D+Tx)(C+D+Ty)C−D, where C is the number of concordant pairs, D is the number of discordant pairs, Tx is the number of pairs tied only in x, and Ty is the number of pairs tied only in y. Pairs tied in both x and y are ignored.
If any denominator is zero, return 0.0 for that coefficient. Do not round inside the function.