Concepts / Ranking Problems

Ranking Problems

A ranking problem asks for something different: it receives several instances and arranges them according to relevance, so the position of each instance matters.

  • Programming

Two Kinds of Prediction

A multiclass prediction chooses one class for an instance from a finite collection of possible classes. A ranking problem asks for something different: it receives several instances and arranges them according to relevance, so the position of each instance matters. This article connects both ideas. It first traces how binary classifiers can be combined into a multiclass predictor, then shows how scores become an ordering in a ranking problem.

Definition

A multiclass predictor assigns each instance to one class from a finite set of possible categories. A ranking hypothesis receives a sequence of instances and determines a permutation of their positions.

The distinction is important. A class prediction answers, “Which category does this instance belong to?” A ranking prediction answers, “In what order should these instances be considered?” The output of a ranking hypothesis is therefore not an isolated label for each instance. It is an ordering of the positions in the input sequence.

One-versus-All Training Sets

One-versus-All builds one binary problem for each class. Suppose the original task has classes A, B, and C. To train the classifier devoted to A, relabel every example from A as +1 and every example from B or C as -1. Repeat the process for B and then for C. Each binary learner therefore separates one selected class from the rest of the classes.

x1Ax1+1x2Bx2-1x3Cx3-1A selectednot Anot A
For a selected class, how do the original multiclass labels become positive and negative binary labels?

The relabeling is the central construction step. The examples are not discarded from the original data; their labels are reinterpreted for the selected binary question. The same original training set can therefore produce several binary training sets, one for each class.

Combining Class Evidence

After training one binary predictor for every class, One-versus-All applies all of them to a new instance. The class-specific outputs are compared, and the class with the largest output is selected. This is an argmax decision: choose the class whose predictor supplies the greatest value.

new instanceclassifier Aoutput 0.7argmaxcompare outputsclass Alargest outputclassifier Boutput 0.4classifier Coutput 0.2evaluateevaluateevaluate0.70.40.2select maximum
How do several class-specific binary predictions flow into one multiclass prediction?
Worked example

Selecting from Real-Valued Outputs

Three One-versus-All predictors return outputs 0.7 for class A, 0.4 for class B, and 0.2 for class C.

  1. 1
    Collect

    Apply all three binary predictors to the same new instance.

  2. 2
    Compare

    Compare the three outputs because the values provide class-specific evidence.

  3. 3
    Select

    The largest value is 0.7, supplied by the predictor for class A.

Result

The combined multiclass prediction is class A.

All-Pairs Classifiers

All-Pairs uses a different reduction. Instead of training one classifier against the entire remainder, it trains one binary classifier for every pair of distinct classes. For a pair of classes i and j, keep only examples labeled i or j, mark class i as +1, mark class j as -1, and train a predictor for that pair.

class 1h1,21 versus 2class 2h1,31 versus 3class 3h2,32 versus 3paired withpaired withpaired withpaired withpaired withpaired with
Which binary classifier is trained for each pair of classes in a three-class problem?

With three classes, the pairwise classifiers are class 1 versus class 2, class 1 versus class 3, and class 2 versus class 3. When a new instance is evaluated, these pairwise decisions are converted into wins. The class with the greatest number of wins becomes the final prediction.

ReductionTraining questionCombination rule
One-versus-AllCan this example be separated into class i versus every other class?Compare class-specific outputs and select the largest, or use tie-breaking for binary outputs.
All-PairsWhich class wins between class i and class j?Count pairwise wins and select the class with the highest count.

Both methods reuse binary learning, but they create different binary problems and combine their outputs differently.

Reduction Failure Modes

A reduction method can make each binary component look reasonable while the combined multiclass predictor behaves poorly. The binary problems do not contain exactly the same information as the original multiclass decision. One-versus-All changes the question into several class-versus-rest questions, while All-Pairs keeps only two classes in each training set. The final rule must reconstruct one coherent multiclass decision from those partial views.

multiclass taskclasses A, B, COne-versus-AllA versus rest; B versusrest; C versus restmulticlass outputone selected classAll-PairsA versus B; A versus C; Bversus Cpartial class evidencepartial pair evidenceargmax or tie-breakcount wins
What information is represented by the reduced binary problems, and where can inconsistency appear?
  • Common mistake

    Assuming that accurate binary classifiers automatically guarantee an accurate multiclass classifier.

    What it looks like

    Each One-versus-All predictor appears acceptable when considered separately, but their outputs do not combine into a useful final decision.

    Why it fails

    The final multiclass construction has its own behavior and must be checked as a whole.

    Do this instead

    Evaluate both the binary components and the rule that combines their outputs.

  • Common mistake

    Ignoring ties when binary One-versus-All outputs are used.

    What it looks like

    More than one class-specific classifier returns +1.

    Why it fails

    A set of positive binary outputs does not by itself identify one unique class.

    Do this instead

    Specify and inspect a tie-breaking rule.

  • Common mistake

    Treating a pairwise result as the final multiclass answer.

    What it looks like

    The classifier for class A versus class B chooses A, but the other pairwise comparisons are not considered.

    Why it fails

    All-Pairs combines the complete set of pairwise outcomes by counting wins.

    Do this instead

    Collect the pairwise outcomes before selecting the class with the highest number of wins.

  • Common mistake

    Confusing ranking with independent class labels.

    What it looks like

    Assigning a separate category to each instance without considering the other instances.

    Why it fails

    A ranking task requires an order in which positions matter.

    Do this instead

    Represent the result as a permutation of the input positions.

Scores Become an Ordering

A ranking hypothesis receives a sequence of instances, written as x̄ = (x1, ..., xr), where r is the number of instances. It produces an ordering of the positions 1 through r. One convenient representation is a score vector y: one score for each instance. Sorting the scores and tracking the original positions produces a permutation, written as π(y).

instance sequence(x1, x2, x3)ranking hypothesis hassign scoresscore vector y(0.2, 0.9, 0.5)permutation π(y)ordered positionsinputproducesort and track positions
How does a ranking hypothesis transform a sequence of instances into scores and an ordered permutation?

The input is a sequence rather than one isolated instance. The output preserves the instances but specifies the order in which their positions should be read. This makes ranking different from multiclass classification: classification selects a category, while ranking arranges the supplied instances.

Worked example

Sorting Scores into Positions

Three instances receive the score vector y = (0.2, 0.9, 0.5). Use ascending sorting to expose the permutation.

  1. 1
    Keep the original positions

    The score 0.2 belongs to position 1, 0.9 belongs to position 2, and 0.5 belongs to position 3.

  2. 2
    Sort the values

    Ascending order gives 0.2, 0.5, 0.9.

  3. 3
    Track the source positions

    Those sorted values came from positions 1, 3, and 2.

Result

The ascending ordering lists positions 1, 3, 2. The top-ranked instances under the source's highest-value interpretation are those associated with the highest positions in the ranking.

x1score 0.2position 1x1x2score 0.9position 2x3x3score 0.5position 3x20.2 is first ascending0.5 is second ascending0.9 is third ascending
Given one score for each instance, how does sorting identify the original position at each place in the ordering?

Practice Trace

MEDIUM

A three-class One-versus-All system produces outputs 0.3, 0.8, and 0.5 for classes A, B, and C. Which class is selected by the argmax rule? Then consider a ranking score vector y = (0.6, 0.1, 0.9). Under ascending sorting, which original positions appear in the resulting permutation?

Hints
  • For the multiclass part, select the largest class-specific output.
  • For the ranking part, write the scores in ascending order and keep the original position attached to each score.
Worked example

Practice Reveal

Use the outputs 0.3, 0.8, and 0.5 for classes A, B, and C, and use ascending sorting for y = (0.6, 0.1, 0.9).

  1. 1
    Multiclass choice

    The largest output is 0.8, which belongs to class B.

  2. 2
    Ranking order

    The ascending score order is 0.1, 0.6, 0.9. These values came from positions 2, 1, and 3.

Result

The multiclass prediction is class B, and the ascending ranking permutation is positions 2, 1, 3.

Key Takeaways

  1. 1
    Multiclass classification chooses one class from a finite set, while ranking arranges several instances by relevance.
  2. 2
    One-versus-All creates one class-versus-rest binary training set for every class and combines the outputs with an argmax or a tie-breaking rule.
  3. 3
    All-Pairs creates one binary classifier for every pair of classes and combines the results by counting pairwise wins.
  4. 4
    Reduction methods can lose useful multiclass relationships or produce outputs that combine poorly, so the final construction must be evaluated as a whole.
  5. 5
    A ranking hypothesis maps an input sequence to an ordering of its positions; a score vector induces that ordering when its values are sorted and their original positions are tracked.

At a glance

  • Multiclass prediction selects one category from a finite collection, whereas ranking produces an ordered list of instances.
  • One-versus-All relabels one class as positive and all other classes as negative for each binary learner.
  • All-Pairs trains a classifier for every pair of classes and uses pairwise wins to choose the final class.
  • Binary components can be individually reasonable while their combined multiclass behavior is poor.
  • A ranking score vector becomes a permutation when its values are sorted and the original positions are preserved.

Related concepts

More concepts starting with R