53. Sentiment Analysis Project in Python
53.4 Traps and Guardrails
53.4 Traps आणि guardrails
TF-IDF सर्व text वर fit, stratify skip, 10 rows वर 90% celebrate — real mistakes.
हे का शिकायचं?
Why. Real mistakes: सर्व text वर TF-IDF fit, stratify skip, 10 rows वर 90% celebrate, किंवा baseline check न करता Hinglish noise ship.
हे काय आहे?
What. आधीच्या chapters चे guardrails अजून लागू: आधी split, classes skew असतील तर accuracy पलीकडले metrics, आणि honest demo size.
कसं करायचं?
How.
हे traps टाळा
- Vectoriser train+test एकत्र fit करू नका.
- Reproducible demos साठी random_state ठेवा.
- Tiny sets वर metrics = smoke tests.
- Add more labelled lines before business decisions.
# BAD: leaks test vocabulary into the vectoriser
# vec.fit_transform(docs) # then split — do not do this
# GOOD: split first, then fit on X_train only (see 53.2)
print("Remember: split → fit vectoriser on train → transform test")