Class AveragePrecisionCorrelation

java.lang.Object
it.unimi.dsi.law.stat.CorrelationIndex
it.unimi.dsi.law.stat.AveragePrecisionCorrelation

public class AveragePrecisionCorrelation
extends CorrelationIndex
Computes the AP (average-precision) correlation between two score vectors without ties. More precisely, this class computes the formula given by Emine Yilmaz, Javed A. Aslam, and Stephen Robertson in “A new rank correlation coefficient for information retrieval”, Proc. of the 31st annual international ACM SIGIR conference on Research and development in information retrieval, pages 587−594, ACM, 2008, using the algorithm described by Sebastiano Vigna in “A weighted correlation index for rankings with ties”, 2014.

This class is a singleton: methods must be invoked on INSTANCE. Additional methods inherited from CorrelationIndex make it possible to compute directly AP correlation bewteen two files, to bound the number of significant digits, or to reverse the standard association between scores and ranks (by default, a larger score corresponds to a higher rank, i.e., to a smaller rank index; the largest score gets rank 0).

A main method is provided for command-line usage.

  • Field Details

  • Method Details

    • compute

      public double compute​(double[] v0, double[] v1)
      Computes AP correlation between two score vectors.

      Note that this method must be called with some care. More precisely, the two arguments should be built on-the-fly in the method call, and not stored in variables, as the first argument array will be null'd during the execution of this method to free some memory: if the array is referenced elsewhere the garbage collector will not be able to collect it.

      Specified by:
      compute in class CorrelationIndex
      Parameters:
      v0 - the first score vector.
      v1 - the second score vector (inducing the reference ranking).
      Returns:
      AP correlation.
    • main

      public static void main​(String[] arg) throws NumberFormatException, IOException, JSAPException
      Throws:
      NumberFormatException
      IOException
      JSAPException