52. Text Cleaning and TF-IDF in Python
52.5 Practice, Tip and Close
Why. Close when TF-IDF + train-only fit is a habit, then classify sentiment.
How.
Chapter practice
- Build six fictional reviews; split; fit TfidfVectorizer on train only.
- Print shapes and ten feature names.
- Write why fitting the vectoriser on all data (including test) leaks information.
Thodkyaat sangaycha tar (quick recap)
- TF-IDF weights distinctive words higher
- fit on train, transform on test
- ngrams help phrases like "not good"
- Hinglish needs humble expectations + light normalisation
Samajla ka? Next: Chapter 53 — Sentiment Analysis Project in Python.
Ravindra Bagale's Tip
Fit the vectoriser on the train set only, and then transform the test set. If you fit it on all of the reviews, including the test set, test information leaks into the features.
Ravindra Bagale's Tip – मराठी
Vectoriser फक्त train set वर fit करा, आणि नंतर test set ला transform करा. जर तो सर्व reviews वर, test set सहित, fit केला, तर test information features मध्ये leak होते.
Ravindra Bagale's Tip – हिंदी
Vectoriser सिर्फ train set पर fit करें, और फिर test set को transform करें. अगर उसे सभी reviews पर, test set सहित, fit किया, तो test information features में leak होती है.