text-classification-eval
Text Classification Improved by Integrating Bidirectional LSTM with Two-dimensional Max Pooling — Peng Zhou et al. (2016) (arXiv:1611.06639, 2016)
What this evaluates
Evaluates text classification performance across multiple sentiment, subjectivity, question classification, and topic categorization tasks. It probes the model's ability to capture contextual and syntactic features from sequential text using 2D matrix representations and spatial pooling.
Datasets
- MR — total ?; splits: train (-1), test (-1)
- SST-1 — total ?; splits: train (-1), test (-1)
- SST-2 — total ?; splits: train (-1), test (-1)
- Subj — total ?; splits: train (-1), test (-1)
- TREC — total ?; splits: train (-1), test (-1)
- 20Newsgroups — total ?; splits: train (-1), test (-1)
Metrics
accuracy (primary) — range: [0, 1]
- Correct predictions divided by total predictions across all instances.
Macro-F1 — range: [0, 1]
- Unweighted mean of the F1 score computed independently for each class, then averaged across all classes.
Input / output format
Input: Raw text sentences or phrases, tokenized and mapped to a 2D matrix via 300-dimensional pre-trained word embeddings and a bidirectional LSTM layer.
Output: Discrete class labels matching the dataset's taxonomy (e.g., binary sentiment, 5-class sentiment, subjectivity, 6-class question type, or 4-class topic).
Scoring recipe
def compute_metric(predictions, gold_labels, metric_type):
if metric_type == 'accuracy':
return sum(p == g for p, g in zip(predictions, gold_labels)) / len(gold_labels)
elif metric_type == 'Macro-F1':
classes = sorted(set(gold_labels))
f1_scores = []
for c in classes:
tp = sum(1 for p, g in zip(predictions, gold_labels) if p == c and g == c)
fp = sum(1 for p, g in zip(predictions, gold_labels) if p == c and g != c)
fn = sum(1 for p, g in zip(predictions, gold_labels) if p != c and g == c)
prec = tp / (tp + fp) if (tp + fp) > 0 else 0.0
rec = tp / (tp + fn) if (tp + fn) > 0 else 0.0
f1 = 2 * prec * rec / (prec + rec) if (prec + rec) > 0 else 0.0
f1_scores.append(f1)
return sum(f1_scores) / len(f1_scores)
Common pitfalls
- SST-2 training set is significantly larger than listed in summary tables because phrases are used for training but only sentences are scored at test time.
- 20Newsgroups uses a specific 4-category subset (comp, politics, rec, religion) and requires Macro-F1 instead of accuracy.
- Hyperparameters were tuned exclusively on the SST-1 development set, so direct application to other datasets without re-tuning may yield suboptimal results.
Evidence (verbatim from paper)
The evaluation metric of the 20Ng is the Macro-F1 measure followed by the state-of-the-art work and the other five datasets use accuracy as the metric.
Citation
@misc{zhou2016textclassification,
title={Text Classification Improved by Integrating Bidirectional LSTM with Two-dimensional Max Pooling},
author={Peng Zhou et al. (2016)},
year={2016},
note={arXiv:1611.06639}
}
1---2name: text-classification-eval3description: Evaluates text classification performance across multiple sentiment, subjectivity, question classification, and topic categorization tasks. It probes the model's ability to capture contextual and syntactic features from sequential text using 2D matrix representations and spatial pooling. Use when the user wants to benchmark on MR, SST-1, SST-2, Subj, TREC, 20Newsgroups, or asks about evaluating this task. Reports accuracy.4metadata:5 source: https://skillmd.com/skills/qhjqhj00/text-classification-eval6 skill_kind: dataset_eval7 source_arxiv: 1611.066398 bibtex_key: zhou2016textclassification9 confidence: high10---1112# text-classification-eval1314> Text Classification Improved by Integrating Bidirectional LSTM with Two-dimensional Max Pooling — Peng Zhou et al. (2016) (arXiv:1611.06639, 2016)1516## What this evaluates1718Evaluates text classification performance across multiple sentiment, subjectivity, question classification, and topic categorization tasks. It probes the model's ability to capture contextual and syntactic features from sequential text using 2D matrix representations and spatial pooling.1920## Datasets2122- **MR** — total ?; splits: train (-1), test (-1)23- **SST-1** — total ?; splits: train (-1), test (-1)24- **SST-2** — total ?; splits: train (-1), test (-1)25- **Subj** — total ?; splits: train (-1), test (-1)26- **TREC** — total ?; splits: train (-1), test (-1)27- **20Newsgroups** — total ?; splits: train (-1), test (-1)2829## Metrics3031- `accuracy` **(primary)** — range: [0, 1]32 - Correct predictions divided by total predictions across all instances.33- `Macro-F1` — range: [0, 1]34 - Unweighted mean of the F1 score computed independently for each class, then averaged across all classes.3536## Input / output format3738**Input**: Raw text sentences or phrases, tokenized and mapped to a 2D matrix via 300-dimensional pre-trained word embeddings and a bidirectional LSTM layer.3940**Output**: Discrete class labels matching the dataset's taxonomy (e.g., binary sentiment, 5-class sentiment, subjectivity, 6-class question type, or 4-class topic).4142## Scoring recipe4344```python45def compute_metric(predictions, gold_labels, metric_type):46 if metric_type == 'accuracy':47 return sum(p == g for p, g in zip(predictions, gold_labels)) / len(gold_labels)48 elif metric_type == 'Macro-F1':49 classes = sorted(set(gold_labels))50 f1_scores = []51 for c in classes:52 tp = sum(1 for p, g in zip(predictions, gold_labels) if p == c and g == c)53 fp = sum(1 for p, g in zip(predictions, gold_labels) if p == c and g != c)54 fn = sum(1 for p, g in zip(predictions, gold_labels) if p != c and g == c)55 prec = tp / (tp + fp) if (tp + fp) > 0 else 0.056 rec = tp / (tp + fn) if (tp + fn) > 0 else 0.057 f1 = 2 * prec * rec / (prec + rec) if (prec + rec) > 0 else 0.058 f1_scores.append(f1)59 return sum(f1_scores) / len(f1_scores)60```6162## Common pitfalls6364- SST-2 training set is significantly larger than listed in summary tables because phrases are used for training but only sentences are scored at test time.65- 20Newsgroups uses a specific 4-category subset (comp, politics, rec, religion) and requires Macro-F1 instead of accuracy.66- Hyperparameters were tuned exclusively on the SST-1 development set, so direct application to other datasets without re-tuning may yield suboptimal results.6768## Evidence (verbatim from paper)6970> The evaluation metric of the 20Ng is the Macro-F1 measure followed by the state-of-the-art work and the other five datasets use accuracy as the metric.7172## Citation7374```bibtex75@misc{zhou2016textclassification,76 title={Text Classification Improved by Integrating Bidirectional LSTM with Two-dimensional Max Pooling},77 author={Peng Zhou et al. (2016)},78 year={2016},79 note={arXiv:1611.06639}80}81```8283- arXiv: 1611.06639