In a first NLP pipeline, common tasks include text classification or sentiment analysis. The key metrics to check are accuracy, precision, and recall. Accuracy shows overall correct predictions. Precision tells us how many predicted positives are truly positive. Recall shows how many actual positives were found. These metrics help us understand if the pipeline correctly processes and classifies text data.
First NLP pipeline - Model Metrics & Evaluation
Actual \ Predicted | Positive | Negative
-------------------|----------|---------
Positive | 40 | 10
Negative | 5 | 45
Here, True Positives (TP) = 40, False Negatives (FN) = 10, False Positives (FP) = 5, True Negatives (TN) = 45.
Imagine your NLP pipeline detects spam messages. If you want to avoid marking good messages as spam, you focus on high precision. This means fewer false alarms.
If you want to catch all spam messages, even if some good messages get flagged, you focus on high recall. This means fewer missed spam.
Balancing precision and recall depends on what matters more: avoiding false alarms or missing spam.
Good: Accuracy above 85%, precision and recall both above 80%. This means the pipeline correctly classifies most texts and balances false alarms and misses.
Bad: Accuracy above 90% but recall below 20%. This means the pipeline misses many positive cases, which is bad if catching positives is important.
- Accuracy paradox: High accuracy can be misleading if classes are imbalanced.
- Data leakage: Using test data during training inflates metrics falsely.
- Overfitting: Very high training accuracy but low test accuracy means the model memorizes instead of learning.
Your NLP pipeline has 98% accuracy but only 12% recall on positive class. Is it good for production? Why or why not?
Answer: No, it is not good. The low recall means the pipeline misses most positive cases, which can be critical depending on the task. High accuracy alone is not enough.