Created
July 31, 2018 00:01
-
-
Save aaronkub/e3bcddcb8c7afe533f712310022a4372 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
feature_to_coef = { | |
word: coef for word, coef in zip( | |
cv.get_feature_names(), final_model.coef_[0] | |
) | |
} | |
for best_positive in sorted( | |
feature_to_coef.items(), | |
key=lambda x: x[1], | |
reverse=True)[:5]: | |
print (best_positive) | |
# ('excellent', 0.9288812418118644) | |
# ('perfect', 0.7934641227980576) | |
# ('great', 0.675040909917553) | |
# ('amazing', 0.6160398142631545) | |
# ('superb', 0.6063967799425831) | |
for best_negative in sorted( | |
feature_to_coef.items(), | |
key=lambda x: x[1])[:5]: | |
print (best_negative) | |
# ('worst', -1.367978497228895) | |
# ('waste', -1.1684451288279047) | |
# ('awful', -1.0277001734353677) | |
# ('poorly', -0.8748317895742782) | |
# ('boring', -0.8587249740682945) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment