Overview
Theget_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:
labelcolumn (0=fallacy, 1=valid) - Predictions:
resultcolumn (“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:- Accuracy: 84.21%
- Precision: 83.33%
- Recall: 86.96%
- F1 Score: 85.11%
Metrics Explained
Accuracy
Precision
Recall (Sensitivity)
F1 Score
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):- 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.High Precision, Low Recall
Scenario: System only flags obvious fallacies.Balanced Performance
Handling Missing Values
Empty predictions (from processing errors) are treated as “Valid”:- Avoids false fallacy accusations
- Penalizes recall (increases false negatives)
- Reflects real-world system behavior
Confusion Matrix Analysis
Extend the script for detailed analysis: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:Next Steps
After evaluating performance:- Error Analysis: Review false positives and false negatives
- Prompt Refinement: Adjust prompts based on error patterns
- Model Comparison: Test different LLMs or NLI models
- Dataset Expansion: Evaluate on diverse fallacy types
- Ablation Studies: Test impact of each pipeline component
