Classification-Evaluation Measures

 

πŸ“Š Classification Performance Measures


🧠 Problem Setup

Let:

  • DD → Testing dataset containing nn data points
  • Each point lies in a dd-dimensional space
  • {c1,c2,,ck}\{c_1, c_2, \dots, c_k\} → Set of kk class labels
  • MM → Classification model (classifier)

πŸ” For each data point xiD:

  • yiy_i → True class label
  • y^i=M(xi)\hat{y}_i = M(x_i)Predicted class label

🎯 Classification Accuracy and Its Limitations


✅ Classification Accuracy

πŸ”Ή Definition

Classification accuracy is the ratio of correctly predicted instances to the total number of instances.


πŸ“ Formula

Accuracy=Number of Correct PredictionsTotal Number of Predictions\text{Accuracy} = \frac{\text{Number of Correct Predictions}}{\text{Total Number of Predictions}}

πŸ“Š Percentage Form

Accuracy (%)=(Correct PredictionsTotal Predictions)×100\text{Accuracy (\%)} = \left( \frac{\text{Correct Predictions}}{\text{Total Predictions}} \right) \times 100


⚠️ Misclassification Rate (Error Rate)

Accuracy can be converted into error rate by taking its complement.


πŸ“ Formula

Error Rate (%)=(1Correct PredictionsTotal Predictions)×100\text{Error Rate (\%)} = \left(1 - \frac{\text{Correct Predictions}}{\text{Total Predictions}} \right) \times 100


πŸ” Interpretation

  • High accuracy → Model makes more correct predictions
  • Low error rate → Model makes fewer mistakes

πŸ“Œ Key Insight

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

🎯 Summary

MeasureMeaning
Accuracy        Proportion of correct predictions
Error Rate        Proportion of incorrect predictions

🧠 Why Evaluation Measures Matter

In classification, accuracy alone is often misleading, especially when:

  • Classes are imbalanced
  • Costs of errors differ
  • We care about specific types of mistakes

πŸ‘‰ Evaluation measures help us understand how well a model performs in different aspects.

πŸ“Š Limitations of Classification Accuracy

Classification accuracy is a good starting point for evaluating a model, but it often fails in practical scenarios.


⚠️ Main Problem

The key issue with accuracy is that:

It hides important details needed to properly understand model performance.


πŸ” Situations Where Accuracy Fails


1. Multi-Class Classification Problem

When your dataset has more than two classes:

  • You might get an accuracy of 80%
  • But this does not tell you:
    • Whether all classes are predicted equally well
    • Or if the model is ignoring some classes

πŸ‘‰ Example issue:

  • Model performs well on 2 classes
  • Performs poorly on 1 class
  • Overall accuracy still looks high

2. Imbalanced Dataset Problem

When class distribution is uneven:

  • Example:
    • 90% of data belongs to one class
    • 10% belongs to another

πŸ”Ή What happens?

  • Model predicts only the majority class
  • Achieves 90% accuracy

πŸ‘‰ But:

  • Model is useless for detecting the minority class

🎯 Key Insight

High accuracy does not necessarily mean a good model.


🧠 Why Accuracy is Misleading

  • Does not show class-wise performance
  • Does not distinguish between types of errors
  • Ignores data imbalance

πŸ“Š Solution: Confusion Matrix

To overcome these limitations, we use:

Confusion Matrix


✅ What it provides:

  • Detailed breakdown of predictions:
    • True Positives (TP)
    • False Positives (FP)
    • False Negatives (FN)
    • True Negatives (TN)

🎯 Benefit

  • Helps analyze:
    • Which classes are misclassified
    • Type of errors made by the model
    • Performance per class

πŸ“ŠConfusion Matrix (Foundation)

For binary classification, everything starts with the confusion matrix:

        Predicted Negative    Predicted Positive
Actual Negative        TN (True Negative)        FP (False Positive)
Actual Positives        FN (False Negative)        TP (True Positive)

πŸ” Meaning

  • TP → correctly predicted positives
  • TN → correctly predicted negatives
  • FP → false alarms
  • FN → missed positives

🎯 Accuracy

πŸ“ Formula

Accuracy=TP+TNTP+TN+FP+FN\text{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN}

✅ Interpretation

  • Overall correctness of the model

⚠️ Limitation

  • Misleading for imbalanced datasets

πŸ‘‰ Example:

  • 95% negative data → predicting all negative gives 95% accuracy

πŸ“ŠError Rate

πŸ”Ή Definition

Error rate is the proportion of incorrect predictions made by a classification model.

It measures how often the model is wrong.


πŸ“ Formula

Error Rate=Number of wrong predictionsTotal number of predictions

Using confusion matrix:

Error Rate=FP+FNTP+TN+FP+FN


πŸ” Relation to Accuracy

Accuracy=TP+TNTotal

πŸ‘‰ Therefore:

Error Rate=1Accuracy



πŸ” Precision

πŸ“ Formula

Precision=TPTP+FP\text{Precision} = \frac{TP}{TP + FP}

✅ Interpretation

Of all predicted positives, how many are actually correct?


🎯 Use When:

  • False positives are costly
  • Example: spam detection

πŸ” Recall (Sensitivity / True Positive Rate)

πŸ“ Formula

Recall=TPTP+FN\text{Recall} = \frac{TP}{TP + FN}

✅ Interpretation

Of all actual positives, how many did we detect?


🎯 Use When:

  • Missing positives is costly
  • Example: disease detection

⚖️Precision vs Recall Tradeoff

  • Increasing precision → may reduce recall
  • Increasing recall → may reduce precision

πŸ‘‰ Controlled via decision threshold


🎯F1 Score

πŸ“ Formula

F1=2PrecisionRecallPrecision+RecallF1 = 2 \cdot \frac{\text{Precision} \cdot \text{Recall}}{\text{Precision} + \text{Recall}}

✅ Interpretation

  • Harmonic mean of precision and recall
  • Balances both metrics

🎯 Use When:

  • Need balance between precision and recall
  • Imbalanced datasets

πŸ“Š  Specificity (True Negative Rate)

πŸ“ Formula

Specificity=TNTN+FP\text{Specificity} = \frac{TN}{TN + FP}

✅ Interpretation

Ability to correctly identify negatives


πŸŽ“Intuitive Examples


Medical Diagnosis

  • Focus: Recall
    πŸ‘‰ Missing a disease is dangerous

Spam Detection

  • Focus: Precision
    πŸ‘‰ Avoid marking real emails as spam

πŸ“š  Significance in Machine Learning

Evaluation metrics help:

  • Compare models objectively
  • Tune hyperparameters
  • Detect overfitting
  • Align model with real-world goals

🎯 Key Takeaways

  • No single metric is sufficient
  • Choice depends on problem context
  • Confusion matrix is fundamental
  • Precision–Recall tradeoff is critical
  • Use multiple metrics for robust evaluation

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