rankings_from_matrix

heterogeneity.rankings_from_matrix(matrix, polarity)

Turn a method by dataset score matrix into a per-dataset ranking matrix.

Each dataset (a column) becomes one ranking of the methods: rank 1 is the best method on that dataset, ties share a rank (competition ranking), and a method with a missing score is left out of that dataset’s ranking, encoded as 0 in the PlackettLuce convention. “Best” is resolved through the metric polarity.

Parameters

Name Type Description Default
matrix np.ndarray Array of shape (n_methods, n_datasets) for one metric. required
polarity str "higher_is_better" or "lower_is_better". required

Returns

Type Description
numpy.ndarray Integer array of shape (n_datasets, n_methods) with rank 1 for the best method, ties shared, and 0 for a method absent from that ranking.

Raises

Type Description
ValueError If matrix is not 2D, has fewer than two methods, or polarity is not recognised.