Skip to main content

Overview

The get_metrics.py script calculates standard classification metrics to evaluate the performance of the NL2FOL system on logical fallacy detection tasks.

How It Works

1

Load Results CSV

Reads the results file generated by fol_to_cvc.py containing predictions.
2

Extract Labels and Predictions

  • Ground truth labels: label column (0=fallacy, 1=valid)
  • Predictions: result column (“LF”=fallacy, “Valid”=valid)
3

Convert to Numerical Format

Maps categorical results to binary format:
  • “LF” → 0 (fallacy)
  • “Valid” → 1 (valid)
  • Empty/Error → 1 (conservative fallback)
4

Calculate Metrics

Computes accuracy, precision, recall, and F1 score using scikit-learn.
5

Display Results

Prints the metrics as a tuple: (accuracy, precision, recall, f1)

Command Usage

Basic Command

Parameters

string
required
Path to the CSV file containing results from fol_to_cvc.py.Expected format: results/<run_name>_results.csvRequired columns:
  • label - Ground truth (0 or 1)
  • result - Prediction (“LF”, “Valid”, or empty)

Example Usage

Output Format

The script outputs a tuple of four metrics:
Example Output:
Interpreted as:
  • Accuracy: 84.21%
  • Precision: 83.33%
  • Recall: 86.96%
  • F1 Score: 85.11%

Metrics Explained

Accuracy

Percentage of correct predictions (both valid arguments and fallacies). Interpretation: Overall correctness of the system.

Precision

Of all arguments marked as fallacies, what percentage are actually fallacies? Interpretation: How reliable are fallacy detections? High precision means few false alarms.

Recall (Sensitivity)

Of all actual fallacies, what percentage are detected? Interpretation: How many fallacies are caught? High recall means few fallacies slip through.

F1 Score

Harmonic mean of precision and recall. Interpretation: Balanced measure of overall performance.
F1 score is particularly useful when classes are imbalanced or when both false positives and false negatives are equally important.

Label Encoding

The script inverts labels because it evaluates fallacy detection (not validity detection):
After inversion:
  • 1 = Fallacy
  • 0 = Valid argument

Implementation Details

Core Function

Full Script Structure

Understanding Results

High Accuracy, Low Precision

Scenario: System predicts “valid” for most arguments.
Interpretation: Catches most fallacies but has many false positives.

High Precision, Low Recall

Scenario: System only flags obvious fallacies.
Interpretation: When it flags a fallacy, it’s usually correct, but misses many fallacies.

Balanced Performance

Interpretation: Well-balanced system with consistent performance.
For fallacy detection in educational contexts, prioritize recall (don’t miss fallacies).For automated content moderation, prioritize precision (avoid false accusations).

Handling Missing Values

Empty predictions (from processing errors) are treated as “Valid”:
This conservative approach:
  • Avoids false fallacy accusations
  • Penalizes recall (increases false negatives)
  • Reflects real-world system behavior
Alternative: Filter out missing values before evaluation:

Confusion Matrix Analysis

Extend the script for detailed analysis:
Example Output:

Per-Dataset Analysis

Compare performance across datasets:

Statistical Significance

For comparing models, use bootstrap confidence intervals:

Visualization

Create visual reports:

Export Results

Save metrics to file:

Benchmarking

Compare against baseline methods:

Error Analysis

Identify problem cases:
Common Pitfalls
  1. Label Confusion: Ensure consistent encoding (0/1 vs LF/Valid)
  2. Missing Values: Decide how to handle processing errors
  3. Class Imbalance: Consider using balanced accuracy or weighted F1
  4. Data Leakage: Never evaluate on training data

Next Steps

After evaluating performance:
  1. Error Analysis: Review false positives and false negatives
  2. Prompt Refinement: Adjust prompts based on error patterns
  3. Model Comparison: Test different LLMs or NLI models
  4. Dataset Expansion: Evaluate on diverse fallacy types
  5. Ablation Studies: Test impact of each pipeline component
See Development Guide for tips on improving the system.