Concepts / Error of a Classifier

Error of a Classifier

A prediction rule maps a domain point to a label.

  • Programming

From Point to Prediction

A machine-learning learner ultimately needs to produce a way to make predictions. That way is called a prediction rule: a function that takes a domain point and maps it to a label. Once the rule exists, it can be applied to new domain points, such as future papayas, to predict their labels.

What do you think happens?

A new domain point x is passed through a prediction rule h : X → Y. What kind of result should come out?

  • Another domain point
  • A label
  • The training sequence
  • The distribution D
Reveal answer

Answer: A label

The notation h : X → Y expresses that h takes a domain point from X and produces a label in Y.

inputoutputxdomain pointhprediction ruleh(x)predicted label
What happens to a domain point x when it passes through h : X → Y?

Reading h : X → Y

The notation h : X → Y describes the direction of the prediction rule. The symbol X represents the domain of possible input points, and Y represents the set of labels. The rule h accepts a point x from X and produces the label h(x) in Y. The input point is transformed into the label that will be used as its prediction; the rule does not return another domain point.

hprediction rule:has typeXdomain points→maps toYlabels
How should each part of h : X → Y be interpreted?

Suppose a rule is used to predict labels for future papayas. A new papaya is a domain point. Applying h to that point produces a label, which is the rule's prediction for that papaya.

Rules and Learned Hypotheses

Prediction rule is the general concept: any function that takes a domain point and maps it to a label. A learning algorithm is a procedure that produces such a rule. If A denotes the learning algorithm and S denotes the training sequence, then A(S) denotes the hypothesis returned by A after receiving S. Thus, a hypothesis is a particular prediction rule selected from the training sequence, while prediction rule describes the kind of object the learner must produce.

receives Sinputis a particularAlearning algorithmA(S)hypothesisprediction rulemaps points to labelsStraining sequence
How is the general notion of a prediction rule related to the particular hypothesis returned by a learning algorithm?

Where Classification Error Comes From

A classifier is evaluated over randomly selected data points, not by inspecting only one prediction. The distribution D determines how likely the possible domain points are to be selected. The correct labeling function f determines the correct label for a domain point. For a point x, the classifier's prediction is h(x), while the correct label is f(x). An error occurs exactly when h(x) does not equal f(x).

selectsf labelsh labelscompare with h(x)compare with f(x)Dprobability of selecting xxdomain pointclassifier errorincorrect predictionprobabilityfcorrect labeling functionf(x)correct labelh(x)predicted label
How do D and f determine whether a prediction contributes to classifier error?

Classifier error is the probability of an incorrect prediction on a random data point selected according to the underlying distribution. For a prediction rule h, an individual point x contributes to the error when h(x) does not equal f(x).

Tracing Correct and Incorrect Outcomes

To evaluate one point, follow the same comparison every time. First, select x according to D. Next, obtain the classifier's prediction h(x). Then, obtain the correct label f(x). If the two labels match, this point is not an error. If they differ, this point is an error.

apply h and compare fapply h and compare fx₁selected pointh(x₁) = f(x₁)correct predictionx₂selected pointh(x₂) ≠ f(x₂)incorrect prediction
How does each point move through the classifier, and where can h(x) differ from f(x)?

Checking Two Predictions

For a generated example, consider two possible domain points. The classifier predicts h(x₁) = red and the correct label is f(x₁) = red. For x₂, the classifier predicts h(x₂) = red and the correct label is f(x₂) = blue.

Point x₁: The predicted label and correct label match, so x₁ is not an incorrect prediction.

Point x₂: The predicted label and correct label differ, so x₂ is an incorrect prediction.

Only x₂ contributes to classifier error.

Combining Point Probabilities

For a finite set of possible points, calculate classifier error by identifying which points are incorrectly predicted and combining the probabilities of those points. Points with matching predicted and correct labels contribute no error. The total error is therefore the probability mass assigned by D to the points where h(x) does not equal f(x).

excludedincludedincludedx₁D(x₁) = 0.2; correct0.8classifier errorx₂D(x₂) = 0.5; incorrectx₃D(x₃) = 0.3; incorrect
How are individual point probabilities combined into total classifier error?

A Finite Error Calculation

A distribution D selects three possible domain points with probabilities 0.2, 0.5, and 0.3. The classifier is correct on the first point and incorrect on the second and third points. What is the classifier error?

Identify incorrect points: The second and third points are the points where h(x) does not equal f(x).

Use their probabilities: The second point contributes 0.5 and the third point contributes 0.3. The first point contributes nothing because its prediction is correct.

Combine contributions: Add the probabilities of the incorrect points: 0.5 + 0.3 = 0.8.

The classifier error is 0.8, meaning the probability of an incorrect prediction in this generated distribution is 0.8.

Names for the Same Quantity

In this context, generalization error, risk, and true error are synonymous names for classifier error. Each refers to the probability that the prediction rule gives an incorrect label on a randomly selected data point. The quantity depends on both the distribution D and the correct labeling function f, because D determines which points are likely to be selected and f determines which labels are correct.

TermMeaning in this context
Classifier errorProbability of an incorrect prediction on a random data point
Generalization errorThe same probability of an incorrect prediction
RiskThe same quantity
True errorThe same quantity

Common Interpretation Mistakes

  • Treating h(x) as the correct label

    h(x) is the classifier's predicted label. The correct label is f(x).

    Fix: Compare h(x) with f(x) to determine whether the prediction is correct.

  • Confusing one prediction with classifier error

    Classifier error is a probability over randomly selected domain points, not merely the outcome for one point.

    Fix: Use the distribution D and combine the probabilities of all points where h(x) does not equal f(x).

  • Ignoring the distribution D

    The error depends on the probability that a random point is one of the incorrectly classified points.

    Fix: Weight the incorrect outcomes by their probabilities under D.

  • Treating A and A(S) as interchangeable

    A denotes the learning algorithm, while A(S) denotes the hypothesis it returns after receiving training sequence S.

    Fix: Use A for the algorithm and A(S) for the particular prediction rule produced from S.

Apply the Error Test

EASY

A distribution D selects three domain points with probabilities 0.1, 0.6, and 0.3. A classifier is correct on the first and third points and incorrect on the second point. Calculate its classifier error.

Hints
  • Find the points where h(x) does not equal f(x).
  • Add the probabilities of only those incorrect points.

Practice Answer

The second point is the only incorrectly classified point, and its probability under D is 0.6.

Select incorrect probability: Only the second point satisfies h(x) does not equal f(x).

Compute total: Because there is only one incorrect point, the total error is its probability, 0.6.

The classifier error is 0.6.

Key Takeaways

  1. A prediction rule is a function that maps domain points in X to labels in Y.
  2. In h : X → Y, h is the rule, X is the domain of inputs, and Y is the label set.
  3. A learning algorithm A receiving a training sequence S returns the hypothesis A(S), which is a particular prediction rule.
  4. A point is misclassified when h(x) does not equal the correct label f(x).
  5. Classifier error is the probability of misclassification under D; in this context, generalization error, risk, and true error are equivalent names.

Key Takeaways

  • A prediction rule transforms a domain point into a predicted label.
  • The notation h : X → Y describes a map from domain points to labels.
  • A hypothesis A(S) is the particular prediction rule returned by learning algorithm A for training sequence S.
  • Classifier error is determined by the probability, under D, that h(x) differs from f(x).
  • Generalization error, risk, and true error refer to this same probability in the given context.