figure - )in[ ]extract feature names and coefficients vect grid best_estimator_ named_steps['tfidfvectorizer'feature_names np array(vect get_feature_names()coef grid best_estimator_ named_steps['logisticregression'coef_ mglearn tools visualize_coefficients(coeffeature_namesn_top_features= figure - most important features when using unigramsbigramsand trigrams with tf-idf rescaling there are particularly interesting features containing the word "worththat were not present in the unigram model"not worthis indicative of negative reviewwhile "definitely worthand "well worthare indicative of positive review this is prime example of context influencing the meaning of the word "worth nextwe'll visualize only trigramsto provide further insight into why these features are helpful many of the useful bigrams and trigrams consist of common words that would not be informative on their ownas in the phrases "none of the""the only good""on and on""this is one""of the most"and so on howeverthe impact of these features is quite limited compared to the importance of the unigram featuresas you can see in figure - in[ ]find -gram features mask np array([len(feature split(")for feature in feature_names]= visualize only -gram features mglearn tools visualize_coefficients(coef ravel()[mask]feature_names[mask]n_top_features= bag-of-words with more than one word ( -grams