HomeData ScienceBag-of-Words vs TF-IDF

🔤 Bag-of-Words vs TF-IDF

A 3D term-weight bar chart that compares Bag-of-Words counts against TF-IDF weights across negative, neutral and positive tweets, showing how TF-IDF suppresses ubiquitous stopwords and boosts distinctive sentiment words.

Data Science3DAdvanced60 FPS
bag-of-words-vs-tfidf-tweet-sentiment-classification-lab ↗ Open standalone

A 3D bar chart of term weights across negative, neutral and positive tweets, comparing raw Bag-of-Words counts against TF-IDF weighting so you can see exactly which words a TF-IDF classifier learns to trust.

🔬 What It Demonstrates

Bag-of-Words treats every occurrence equally, so filler words like "the", "amp" and "http" tower over sentiment-bearing words. TF-IDF multiplies each count by an inverse-document-frequency term, shrinking ubiquitous words and preserving rare, class-distinctive ones.

🎮 How to Use

Toggle between Bag-of-Words and TF-IDF, highlight a sentiment class, and drag the document-frequency and corpus-size sliders to see how the idf formula reshapes the bar for "the" in real time.

💡 Did You Know?

The "signal / stopword ratio" stat approximates why TF-IDF often beats plain Bag-of-Words on short, noisy text: it boosts the ratio of sentiment signal to boilerplate noise without any extra model complexity.

⚙ Under the hood

A 3D term-weight bar chart that compares Bag-of-Words counts against TF-IDF weights across negative, neutral and positive tweets, showing how TF-IDF suppresses ubiquitous stopwords and boosts distinctive sentiment words.

text-analysissentiment-analysistf-idfbag-of-wordsnlpmachine-learningThree.js

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)