IntimateUser6969/text-classification-comparison
Text Classification Comparison: Supervised vs Unsupervised on stanfordnlp/imdb Dataset stanfordnlp/imdb (Maas et al., 2011) 50,000 IMDB movie reviews: 25,000 train / 25,000 test Binary sentiment: 0 (negative) / 1 (positive), perfectly balanced in both splits Preprocessing: TF-IDF (15,000 features, bigrams, sublinear TF, min_df=3) Models Chosen Model Type Key Reference Why Logistic Regression Linear supervised McFadden (1974); Ng &… See the full description on the dataset page: https://huggingface.co/datasets/IntimateUser6969/text-classification-comparison.
Text Classification Comparison: Supervised vs Unsupervised on stanfordnlp/imdb
Dataset
stanfordnlp/imdb (Maas et al., 2011)
- 50,000 IMDB movie reviews: 25,000 train / 25,000 test
- Binary sentiment: 0 (negative) / 1 (positive), perfectly balanced in both splits
- Preprocessing: TF-IDF (15,000 features, bigrams, sublinear TF, min_df=3)
Models Chosen
Results (Test Set: 25,000 reviews)
Best Model: Logistic Regression (Accuracy=0.898, F1=0.899, AUC=0.962)
Why Logistic Regression Wins
- Text classification is approximately linear: Sentiment in IMDB reviews is largely encoded in word-level cues (positive words like "great", "lovely" vs negative words like "bad", "poor"). TF-IDF features are highly sparse and high-dimensional (15,000 features). Regularized linear models are optimal in this regime.
- No overfitting from high sparsity: The L2-regularized logistic regression finds a stable decision across the full vocabulary. Tree ensembles over-fit to rare word co-occurrences in sparse TF-IDF (most features are zero — ~99.7% of the 15,000 features are zero per sample).
- Feature interactions captured by bigrams: TF-IDF includes unigrams and bigrams (ngram_range=(1,2)), which captures sentiment-carrying phrases ("not good", "very bad"). Logistic Regression leverages these directly as features, while tree models need many deep splits to approximate the same interactions.
- Random Forest (0.84 acc) underperforms because:
- Random feature subsampling (default sqrt(p) = 122 features per split) discards important unigram features
- With high sparsity, most tree splits find no informative features at leaf nodes
- Bagging doesn't help when individual trees are weak due to feature sparsity
- XGBoost/LightGBM close second (0.87 acc, ~0.94 AUC) but require 54s vs 2.8s for LR
- KMeans as expected: As an unsupervised approach, KMeans achieved 0.44 accuracy with ROC-AUC of 0.41 (below random). This confirms that without label supervision, word-frequency clustering cannot recover the sentiment signal.
References
- Maas, et al. (2011). Learning Word Vectors for Sentiment Analysis. ACL.
- Ng, Jordan (2000). On Discriminative vs Discriminative Learning. ICML.
- Breiman (2001). Random Forests. Machine Learning.
- Chen, Guestrin (2016). XGBoost. KDD.
- Ke, et al. (2017). LightGBM. NeurIPS.
- Vapnik (1995). The Nature of Statistical Learning Theory.
- Xie, et al. (2021). A Survey of K-Means Clustering. arXiv:2112.06310.
<!-- ml-intern-provenance -->
Generated by ML Intern
This dataset repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.
- Try ML Intern: https://smolagents-ml-intern.hf.space
- Source code: https://github.com/huggingface/ml-intern
Usage
from datasets import load_dataset
dataset = load_dataset('IntimateUser6969/text-classification-comparison')