When you compare more than two models over several datasets, pairwise t-tests inflate the error rate. The Friedman test (Demsar, 2006) ranks the models within each dataset, then tests whether the average ranks differ.
Given a (N, k) score matrix where higher is better, rank each row from 1 (best) to k (worst), with tied scores receiving the average of their ranks. Let R_j be the sum of algorithm j's ranks over the N datasets. Then
chi2_F = 12 / (N k (k + 1)) * sum_j R_j^2 - 3 N (k + 1).
Implement friedman_statistic(scores) and return chi2_F as a float.
scores is 2-D with N >= 1 rows and k >= 2 columns. Otherwise raise ValueError.ValueError.Use scipy.stats.rankdata only if you are sure it is available. Otherwise, a rank per row with ties averaged is enough: for each row, sort and average the positions of equal values.
No results yet
Run your code to check it against the examples, or submit to run every test.