Numerical Problems- Classification Measures

Example:

Consider a Bayes classifier, which miss classifies 8 out of 30 test cases .Then find the accuracy and error rate.

๐Ÿง  Given

  • Total test cases = 30
  • Misclassified cases = 8

๐Ÿ”น Step 1: Correct Predictions

Correct Predictions=308=22\text{Correct Predictions} = 30 - 8 = 22

๐Ÿ”น Step 2: Compute Accuracy

Accuracy=2230=0.733

๐Ÿ‘‰ Accuracy = 0.733 (or 73.3%)


๐Ÿ”น Step 3: Compute Error Rate

Error Rate=830=0.267

๐Ÿ‘‰ Error Rate = 0.267 (or 26.7%)


๐ŸŽฏ Final Answer

MeasureValue
Accuracy        0.733 (73.3%)
Error Rate        0.267 (26.7%)

๐Ÿ“Œ Key Insight

Error Rate=1Accuracy\text{Error Rate} = 1 - \text{Accuracy}

Example:

Imagine an application that is developed to recognize cats and dogs. This identifies eight dogs in a picture containing 12 dogs and some cats. Of the eight dogs identified, five actually are dogs while the rest are cats. Compute the True Positive, False Positive and False Negative values.

๐Ÿ“Š Confusion Matrix

๐Ÿง  Recall from the problem:

  • TP = 5 (dogs correctly identified)
  • FP = 3 (cats identified as dogs)
  • FN = 7 (dogs missed)

We are not given total number of cats, so TN cannot be determined.


๐Ÿ“‹ Matrix Representation

        Predicted Dog        Predicted Cat
Actual Dog            TP = 5            FN = 7
Actual Cat                        FP = 3            TN = ?

Example:
For a classifier, the confusion matrix is given.What is the precision, recall and accuracy of that classifier?

๐Ÿ“Š Performance Metrics from Confusion Matrix

Given:

  • TP = 9, FP = 1, FN = 9, TN = 5
  • Total samples n=24n = 24

๐Ÿ”น 1. Precision (Positive Class)

PrecisionP=TPTP+FP=99+1=910=0.9\text{Precision}_P = \frac{TP}{TP + FP} = \frac{9}{9 + 1} = \frac{9}{10} = 0.9

๐Ÿ‘‰ Precision (Positive) = 0.9


๐Ÿ”น 2. Precision (Negative Class)

PrecisionN=TNTN+FN=55+9=514=0.357\text{Precision}_N = \frac{TN}{TN + FN} = \frac{5}{5 + 9} = \frac{5}{14} = 0.357

๐Ÿ‘‰ Precision (Negative) ≈ 0.357


๐Ÿ”น 3. Recall (Positive Class / Sensitivity / TPR)

RecallP=TPTP+FN=99+9=918=0.5\text{Recall}_P = \frac{TP}{TP + FN} = \frac{9}{9 + 9} = \frac{9}{18} = 0.5

๐Ÿ‘‰ Recall (Positive) = 0.5


๐Ÿ”น 4. Recall (Negative Class / Specificity / TNR)

RecallN=TNTN+FP=55+1=56=0.83

๐Ÿ‘‰ Recall (Negative) ≈ 0.83


๐Ÿ”น 5. Accuracy

Accuracy=TP+TNn=9+524=1424=0.583\text{Accuracy} = \frac{TP + TN}{n} = \frac{9 + 5}{24} = \frac{14}{24} = 0.583

๐Ÿ‘‰ Accuracy ≈ 0.583 (58.3%)


๐Ÿ“Š Final Summary

Metric    Value
Precision (Positive)    0.90
Precision (Negative)    0.357
Recall (Positive)    0.50
Recall (Negative)    0.83
Accuracy    0.583

Example


๐Ÿ“Š Confusion Matrix Interpretation

Actual Spam    Actual Not Spam
Predicted Spam    TP = 70    FP = 30
Predicted Not Spam    FN = 70    TN = 330

๐Ÿง  1. Precision (for Spam)

Precision=TPTP+FP=7070+30=70100=0.7\text{Precision} = \frac{TP}{TP + FP} = \frac{70}{70 + 30} = \frac{70}{100} = 0.7

๐Ÿ‘‰ Precision = 0.7 (70%)


๐Ÿง  2. Recall (for Spam)

Recall=TPTP+FN=7070+70=70140=0.5\text{Recall} = \frac{TP}{TP + FN} = \frac{70}{70 + 70} = \frac{70}{140} = 0.5

๐Ÿ‘‰ Recall = 0.5 (50%)



Comments

Popular posts from this blog

Machine Learning PCCST503 Semester5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Machine Learning (ML)

Distinguishing Machine Learning from Traditional Programming