2
$\begingroup$

I have rather a simple question which I have not had any luck finding the answer to. I'm training a Random Forest classifier using sklearn in Python 2.7, on a large dataset ~(80k,250) where observations are movie reviews and features are attributes of critic and movie. Targets are "positive review" (1) or "negative review" (0).

My reason for training this classifier is so I can investigate feature importances. Just extracting the feature importances is a simple task, using feature_importances_. This produces an array of GINI estimates for each feature. What this, however, does not tell me is which classification ("pos"/"neg") that a specific feature is typical to. In other words, does having Clint Eastwood in your movie affect the scores given by critics positively or negatively?

Is there a simple way to get these class-specific feature importances? Is there a complicated way? Is there a way at all?

$\endgroup$
1
$\begingroup$

The simplest method I could think of is finding the ratio between the "positive" and "negative" rows where your feature is present. I.e. for all movies where Clint Eastwood is playing, what is the ratio between positive reviews and negative reviews? Are there many more positive than negative reviews?

I suppose there are different formulas you could use - pos/neg, pos/(pos+neg), pos-neg, etc.

$\endgroup$
  • $\begingroup$ Thanks for your response! I did think of that very method, and if nothing else works that is what I will use in my analysis. Only problem is that this sort of beats the purpose of training a classifier at all. I'm basically just summing over the rows of my vectorized matrix. Not that there's anything wrong with that through :) $\endgroup$ – Ulf Aslak May 11 '15 at 12:20
  • $\begingroup$ Ok I just implemented this and it actually gives some good results. Clint Eastwood will bump your movie score up by 36 percent it turns out. $\endgroup$ – Ulf Aslak May 11 '15 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.