Ravindra BagaleCourses & study guides English Track your progress

53. Sentiment Analysis Project in Python

Data Science

53.3 Inspect Top Tokens

53.3 Top tokens inspect करा

Managers विचारतात “negative का?” — high-weight tokens = trust.

हे का शिकायचं?

Why. Managers विचारतात “negative का?” High-weight tokens inspect केलं की trust वाढतो.

हे काय आहे?

What. Fit नंतर LogisticRegression coef_ vectoriser feature names शी जुळतो. Positive coefs → positive class; negative coefs → negative (binary 0/1).

कसं करायचं?

How.

Top tokens peek

  1. 53.2 मधला fitted vec आणि clf reuse.
  2. Feature names coefficients शी zip.
  3. दोन्ही बाजू strongest tokens sort+print.
import numpy as np

# assumes vec, clf from previous cell
feats = np.array(vec.get_feature_names_out())
coefs = clf.coef_[0]
order = np.argsort(coefs)
print("lean negative:", feats[order[:5]])
print("lean positive:", feats[order[-5:]])

Ravindra Bagale's Tip

On a tiny dataset, the coef_ values can be noisy and can change a lot with a few more rows. Use the top tokens to see the general pattern, but do not overclaim what they prove.