A third view of the task of a recommender system is that it ranks all items with respect to a user (or ranks all user-item pairs), such that the higher-ranked recommendations are more likely to be relevant to users. Individual rating predictions may be incorrect, but, as long as the order is caught correctly, rank accuracy measures will evaluate the system as having a high accuracy.
If the variance of one variable can be explained by the variance in another, the two variables are said to correlate. Let be items and be their true order rank. Let the recommender system predict the ranks for these items (i.e., is the true rank of the item and is the predicted rank). Let be the mean of , and be the mean of . The Spearman's correlation is defined as follows:
The following code finds the coefficient:
This produces the following output:
val p : float = 0.9338995047...