tweettopic-eval
Twitter Topic Classification — Antypas et al. (2022) (arXiv:2209.09824, 2022)
What this evaluates
Evaluates language models on classifying tweets into predefined topics, testing both single-label and multi-label classification capabilities. It probes robustness to social media noise, short-form content, and topic overlap in real-world settings.
Datasets
- TweetTopic — total 11267; splits: train (-1), test (-1)
Metrics
Macro Precision — range: percent
- Calculated per class as TP/(TP+FP), then averaged across all classes.
Macro Recall — range: percent
- Calculated per class as TP/(TP+FN), then averaged across all classes.
Macro F1 (primary) — range: percent
- Harmonic mean of macro Precision and macro Recall, averaged across all classes.
Accuracy — range: percent
- Proportion of correctly classified tweets out of the total.
Jaccard Index — range: percent
- For each tweet, size of intersection over union of predicted and true label sets. Final metric is the average over all tweets.
Input / output format
Input: Raw tweet text.
Output: A single topic label (single-label) or a set of topic labels (multi-label).
Scoring recipe
def compute_macro_f1(preds, golds, classes):
f1s = []
for c in classes:
tp = sum(1 for p, g in zip(preds, golds) if p == c and g == c)
fp = sum(1 for p, g in zip(preds, golds) if p == c and g != c)
fn = sum(1 for p, g in zip(preds, golds) if p != c and g == c)
prec = tp / (tp + fp) if (tp + fp) > 0 else 0
rec = tp / (tp + fn) if (tp + fn) > 0 else 0
f1s.append(2 * prec * rec / (prec + rec) if (prec + rec) > 0 else 0)
return sum(f1s) / len(f1s)
def compute_jaccard(preds, golds):
scores = []
for p, g in zip(preds, golds):
inter = len(set(p) & set(g))
union = len(set(p) | set(g))
scores.append(inter / union if union > 0 else 0)
return sum(scores) / len(scores)
Common pitfalls
- TimeLM-21 was trained on a corpus overlapping with the test set period, giving it an unfair advantage and inflating its reported performance.
- Multi-label classification is significantly harder than single-label due to label overlap and social media noise, often resulting in much lower F1 scores.
- Macro averaging can mask poor performance on minority topics if not analyzed per-class.
Evidence (verbatim from paper)
For both settings macro average Precision, Recall and F1, as well as Accuracy, are used to evaluate the models tested. As an alternative metric for the multi-label setting, Jaccard Index (JI) is also utilized, as it can offer useful insights about the models performances (Pereira et al., 2018; Tsoumakas et al., 2009). More specifically, the index is calculated for each tweet individually and the final metric is computed as the average over all entries.
Citation
@misc{antypas2022twitter,
title={Twitter Topic Classification},
author={Antypas et al. (2022)},
year={2022},
note={arXiv:2209.09824}
}
1---2name: tweettopic-eval3description: Evaluates language models on classifying tweets into predefined topics, testing both single-label and multi-label classification capabilities. It probes robustness to social media noise, short-form content, and topic overlap in real-world settings. Use when the user wants to benchmark on TweetTopic, or asks about evaluating this task. Reports Macro F1.4---56# tweettopic-eval78> Twitter Topic Classification — Antypas et al. (2022) (arXiv:2209.09824, 2022)910## What this evaluates1112Evaluates language models on classifying tweets into predefined topics, testing both single-label and multi-label classification capabilities. It probes robustness to social media noise, short-form content, and topic overlap in real-world settings.1314## Datasets1516- **TweetTopic** — total 11267; splits: train (-1), test (-1)1718## Metrics1920- `Macro Precision` — range: percent21 - Calculated per class as TP/(TP+FP), then averaged across all classes.22- `Macro Recall` — range: percent23 - Calculated per class as TP/(TP+FN), then averaged across all classes.24- `Macro F1` **(primary)** — range: percent25 - Harmonic mean of macro Precision and macro Recall, averaged across all classes.26- `Accuracy` — range: percent27 - Proportion of correctly classified tweets out of the total.28- `Jaccard Index` — range: percent29 - For each tweet, size of intersection over union of predicted and true label sets. Final metric is the average over all tweets.3031## Input / output format3233**Input**: Raw tweet text.3435**Output**: A single topic label (single-label) or a set of topic labels (multi-label).3637## Scoring recipe3839```python40def compute_macro_f1(preds, golds, classes):41 f1s = []42 for c in classes:43 tp = sum(1 for p, g in zip(preds, golds) if p == c and g == c)44 fp = sum(1 for p, g in zip(preds, golds) if p == c and g != c)45 fn = sum(1 for p, g in zip(preds, golds) if p != c and g == c)46 prec = tp / (tp + fp) if (tp + fp) > 0 else 047 rec = tp / (tp + fn) if (tp + fn) > 0 else 048 f1s.append(2 * prec * rec / (prec + rec) if (prec + rec) > 0 else 0)49 return sum(f1s) / len(f1s)5051def compute_jaccard(preds, golds):52 scores = []53 for p, g in zip(preds, golds):54 inter = len(set(p) & set(g))55 union = len(set(p) | set(g))56 scores.append(inter / union if union > 0 else 0)57 return sum(scores) / len(scores)58```5960## Common pitfalls6162- TimeLM-21 was trained on a corpus overlapping with the test set period, giving it an unfair advantage and inflating its reported performance.63- Multi-label classification is significantly harder than single-label due to label overlap and social media noise, often resulting in much lower F1 scores.64- Macro averaging can mask poor performance on minority topics if not analyzed per-class.6566## Evidence (verbatim from paper)6768> For both settings macro average Precision, Recall and F1, as well as Accuracy, are used to evaluate the models tested. As an alternative metric for the multi-label setting, Jaccard Index (JI) is also utilized, as it can offer useful insights about the models performances (Pereira et al., 2018; Tsoumakas et al., 2009). More specifically, the index is calculated for each tweet individually and the final metric is computed as the average over all entries.6970## Citation7172```bibtex73@misc{antypas2022twitter,74 title={Twitter Topic Classification},75 author={Antypas et al. (2022)},76 year={2022},77 note={arXiv:2209.09824}78}79```8081- arXiv: 2209.09824