public class WeightedTau extends CorrelationIndex
Given two scores vectors for a list of items,
this class provides a method to compute efficiently the weighted τ
using an ExchangeWeigher
.
Instances of this class are immutable. At creation time you can specify a
weigher that turns indices into weights, and
whether to combine weights additively or multiplicatively.
Readymade weighers include HYPERBOLIC_WEIGHER
, which is the weigher of choice. Alternatives include
LOGARITHMIC_WEIGHER
and QUADRATIC_WEIGHER
.
Additional methods inherited from CorrelationIndex
make it possible to
compute directly the weighted τ 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).
The weighted τ is defined as follows: consider a rank function ρ (returning natural numbers or ∞) that provides a ground truth—it tells us which elements are more or less important. Consider also a weight function w(−, −) associating with each pair of ranks a nonnegative real number. We define the rankweighted τ by
The weight function can be specified by giving a weigher f (e.g., HYPERBOLIC_WEIGHER
) and a combination
strategy, which can be additive or multiplicative.
The weight of the exchange between i and j
is then f(i) ● f(j), where ● is the chosen combinator.
Now, consider the rank function ρ_{r, s} induced by the lexicographical order by r and s. We define
In particular, the (additive) hyperbolic τ is defined by the weight function h(i) = 1 / (i + 1) combined additively:
The methods inherited from CorrelationIndex
compute the formula above using the provided weigher
and combination method. A readymade instance HYPERBOLIC
can be used to compute the additive hyperbolic τ. An
ad hoc method can instead compute τ_{ρ,w}.
A main method is provided for commandline usage.
Modifier and Type  Class and Description 

static class 
WeightedTau.AbstractWeigher 
Modifier and Type  Field and Description 

static WeightedTau 
HYPERBOLIC
A singleton instance of the symmetric hyperbolic additive τ.

static Int2DoubleFunction 
HYPERBOLIC_WEIGHER
A hyperbolic weigher (the default one).

static Int2DoubleFunction 
LOGARITHMIC_WEIGHER
A logarithmic weigher.

static Int2DoubleFunction 
QUADRATIC_WEIGHER
A quadratic weigher.

static Int2DoubleFunction 
ZERO_WEIGHER
A constant zero weigher.

Constructor and Description 

WeightedTau()
Create an additive hyperbolic τ.

WeightedTau(Int2DoubleFunction weigher)
Create an additive weighted τ using the specified weigher.

WeightedTau(Int2DoubleFunction weigher,
boolean multiplicative)
Create an additive or multiplicative weighted τ using the specified weigher and combination strategy.

Modifier and Type  Method and Description 

double 
compute(double[] v0,
double[] v1)
Computes the symmetrized weighted τ between two score vectors.

double 
compute(double[] v0,
double[] v1,
int[] rank)
Computes the weighted τ between two score vectors, given a reference rank.

static void 
main(java.lang.String[] arg) 
compute, compute, compute, compute, computeDoubles, computeDoubles, computeDoubles, computeDoubles, computeFloats, computeFloats, computeFloats, computeFloats, computeInts, computeInts, computeLongs, computeLongs, loadAsDoubles, parseInputTypes
public static final Int2DoubleFunction HYPERBOLIC_WEIGHER
public static final Int2DoubleFunction QUADRATIC_WEIGHER
public static final Int2DoubleFunction LOGARITHMIC_WEIGHER
public static final Int2DoubleFunction ZERO_WEIGHER
public static final WeightedTau HYPERBOLIC
public WeightedTau()
public WeightedTau(Int2DoubleFunction weigher)
weigher
 a weigher.public WeightedTau(Int2DoubleFunction weigher, boolean multiplicative)
weigher
 a weigher.multiplicative
 if true, weights are combined multiplicatively, rather than additively.public double compute(double[] v0, double[] v1)
compute
in class CorrelationIndex
v0
 the first score vector.v1
 the second score vector.public double compute(double[] v0, double[] v1, int[] rank)
Note that this method must be called with some care. More precisely, the two
arguments should be built onthefly 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.
v0
 the first score vector.v1
 the second score vector.rank
 the “ground truth” ranking used to weight exchanges, or null
to use the
ranking induced lexicographically by v1
and v0
as ground truth.public static void main(java.lang.String[] arg) throws java.lang.NumberFormatException, java.io.IOException, JSAPException
java.lang.NumberFormatException
java.io.IOException
JSAPException