fgg blog

Class-Importance Weighted F2 Score (F2-CIW)

Table of Contents

# Why Use F2-CIW?

Economic Impact: In the SewerML dataset, certain sewer defects may be more costly or dangerous if undetected, so the model should prioritize accurately classifying these defects.

Handling Class Imbalance: In datasets where some classes are underrepresented but critically important, F2-CIW ensures that these classes are not overshadowed by more frequent, less important classes.

# Traditional F2 Score

The F2 score is a variant of the F1 score, which is the harmonic mean of precision and recall, but it gives more weight to recall. The F2 score is defined as:

$$ F2 = \frac{5 \times \text{Precision} \times \text{Recall}}{4 \times \text{Precision} + \text{Recall}} $$

The F2 score is particularly useful in situations where you care more about capturing as many true positives as possible, even if it means allowing more false positives.

# Class-Importance Weighted F2 Score (F2-CIW)

The Class-Importance Weighted F2 Score (F2-CIW) is a metric that adapts the traditional F2 score to account for the economic or practical importance of different classes in a classification task. This is particularly useful in imbalanced datasets or scenarios where some classes have a higher impact on the overall outcome than others, such as in the SewerML dataset.

In tasks like those involving the SewerML dataset, different classes (e.g., types of sewer defects) may have different levels of importance based on their economic impact or other practical considerations. The F2-CIW metric adjusts the F2 score by assigning a weight to each class that reflects its importance.

## Steps to Compute F2-CIW:

  1. Assign Weights to Classes: Each class $c$ is assigned a weight $w_c$ based on its importance. The weights are typically derived from domain knowledge, such as the economic impact of misclassifying that class.

  2. Compute Per-Class F2 Scores: For each class, compute the F2 score $F2_c$ using the standard formula.

  3. Weighted Average of F2 Scores: The overall F2-CIW is computed as a weighted average of the per-class F2 scores:

$$ F2\text{-CIW} = \frac{\sum_{c} w_c \times F2_c}{\sum_{c} w_c} $$

This approach ensures that classes with higher importance have a more significant influence on the final score.

Overall, F2-CIW provides a more nuanced evaluation metric that aligns the model’s performance with the practical importance of different outcomes.