The interview problem

Practice prompt

Two model scores have different scales. Explain when Spearman correlation is useful and calculate a small example.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Assume paired observations with no ties for the first calculation. Replace each variable with its ranks and compute Pearson correlation of those ranks. This tests monotonic agreement rather than equality of score values. For tied observations, use average ranks and the general correlation formula. Keep pairs together during resampling and state the independent sampling unit before interpreting uncertainty.

2. Trace the design or derivation

Pair observations
  → rank with tie policy
  → correlate ranks
  → assess sampling uncertainty

If x increases monotonically while y rises and then falls, rank correlation may be near zero despite a deterministic relationship. Plot paired data before using one coefficient as a summary. For repeated model comparisons, keep the same evaluation population so changes in correlation do not merely reflect a new score range.

3. Calculate the example

Ranks x=(1,2,3,4) and y=(1,3,2,4) have squared rank differences summing to 2. With no ties, rho=1−6×2/[4×(16−1)]=0.8. This does not mean 80% of predictions are correct.

4. Failure cases and trade-offs

A perfect monotonic transformation can yield rho=1 while probabilities are badly calibrated. Constant inputs make correlation undefined. Rank correlation ignores useful magnitude information and can miss a nonmonotonic relationship. Choose it for ordering agreement, then evaluate calibration or task loss separately.

5. Validation, follow-ups and self-review

Check identical, reversed, tied and constant vectors. Follow-up: how would repeated observations from one user affect a significance test? Self-review: distinguish ranks, calibration and independence; never turn correlation into causation.

Sources and related practice

Technical reference: docs.scipy.org — Rank correlation and small-sample inference cautions.

Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with When can you trust a probability?; Choose pointwise pairwise or listwise ranking losses.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.