Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Multiclass News Classifier

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.


Overview

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.


Approach

Representation

  • 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

Metadata

  • source: one-hot encoding (handle_unknown="ignore")
  • page_rank: median imputation + MaxAbsScaler (sparsity-preserving)

Pipeline

All preprocessing and modeling steps are wrapped in a single:

  • Pipeline
  • ColumnTransformer

This guarantees:

  • No information leakage
  • Correct cross-validation behavior
  • Full reproducibility

Models

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

Results

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.


Error Analysis

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.


Positioning

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.


Technical Scope

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.

About

Sparse NLP baseline with TF–IDF and linear models, optimized for macro-F1

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages