lectures = ['this is some food', 'this is some drink']
vectorizer = TfidfVectorizer(ngram_range=(1, 2))
X = vectorizer.fit_transform(lectures)
features_by_gram = defaultdict(list)
for f, w in zip(vectorizer.get_feature_names(), vectorizer.idf_):
    features_by_gram[len(f.split(' '))].append((f, w))
top_n = 2
for gram, features in features_by_gram.items():
    top_features = sorted(features, key=lambda x: x[1], reverse=True)[:top_n]
top_features = [f[0] for f in top_features]
print('{}-gram top:'.format(gram), top_features)
Как увидеть первые n записей матрицы терминов-документов после tfidf в scikit-learn