Reproducible multi-class news topic classification using sparse TF–IDF representations and linear models.
A controlled, leakage-free baseline focused on methodological rigor rather than architectural complexity.
This project implements an end-to-end text classification pipeline over:
- Title
- Article body
- Metadata (
source,page_rank)
The objective is to build a stable and well-validated baseline under class imbalance, optimized for macro-F1.
- Separate TF–IDF vectorizers for title and article
- Word n-grams (1,2)
- Frequency pruning (
min_df=2,max_df=0.95) - Log-scaled term frequency (
sublinear_tf=True) - Controlled vocabulary size
source: one-hot encoding (handle_unknown="ignore")page_rank: median imputation +MaxAbsScaler(sparsity-preserving)
All preprocessing and modeling steps are wrapped in a single:
PipelineColumnTransformer
This guarantees:
- No information leakage
- Correct cross-validation behavior
- Full reproducibility
Evaluated:
LinearSVC(selected)LogisticRegression
Both trained with:
class_weight="balanced"- Stratified K-fold cross-validation
- Macro-averaged F1
Linear models were intentionally chosen for:
- Stability in high-dimensional sparse space
- Explicit regularization control
- Fast CPU training
| Model | CV Macro-F1 | Validation Macro-F1 |
|---|---|---|
| Logistic Regression | 0.705 | 0.712 |
| Linear SVM | 0.709 | 0.714 |
Public evaluation reference: 0.730 macro-F1
Validation and CV scores remain consistent, suggesting limited overfitting.
Confusion patterns show:
- Strong separability for lexically distinctive classes
- Systematic confusion between semantically overlapping categories (e.g., Business vs Technology)
The primary bottleneck appears to be representational ambiguity rather than model capacity.
This repository prioritizes:
- Leakage-free design
- Controlled model capacity
- Reproducible validation
- Transparent trade-offs
It is a foundational NLP baseline, not a deep-learning benchmark.
This implementation intentionally excludes:
- Contextual embeddings (e.g., transformers)
- Extensive ablation studies
- Production-oriented packaging
The goal is a clean and controlled reference system that can serve as a basis for future extensions.