mglearn tools visualize_coefficientsgrid best_estimator_ named_steps["logisticregression"coef_feature_namesn_top_features= figure - largest and smallest coefficients of logistic regression trained on tf-idf features the negative coefficients on the left belong to words that according to the model are indicative of negative reviewswhile the positive coefficients on the right belong to words that according to the model indicate positive reviews most of the terms are quite intuitivelike "worst""waste""disappointment"and "laughableindicating bad movie reviewswhile "excellent""wonderful""enjoyable"and "refreshingindicate positive movie reviews some words are slightly less clearlike "bit""job"and "today"but these might be part of phrases like "good jobor "best today bag-of-words with more than one word ( -gramsone of the main disadvantages of using bag-of-words representation is that word order is completely discarded thereforethe two strings "it' badnot good at alland "it' goodnot bad at allhave exactly the same representationeven though the meanings are inverted putting "notin front of word is only one example (if an extreme oneof how context matters fortunatelythere is way of capturing context when using bag-of-words representationby not only considering the counts of single tokensbut also the counts of pairs or triplets of tokens that appear next to each other pairs of tokens are known as bigramstriplets of tokens are known as trigramsand more generally sequences of tokens are known as -grams we can change the range of tokens that are considered as features by changing the ngram_range parameter of countvectorizer or tfidfvectorizer the ngram_range parameter is tupleconbag-of-words with more than one word ( -grams