我需要为文本构建一个分类器,现在我使用 TfidfVectorizer 和 SelectKBest 来选择特征,如下所示:
vectorizer = TfidfVectorizer(sublinear_tf = True, max_df = 0.5, stop_words = 'english',charset_error='strict')
X_train_features = vectorizer.fit_transform(data_train.data)
y_train_labels = data_train.target;
ch2 = SelectKBest(chi2, k = 1000)
X_train_features = ch2.fit_transform(X_train_features, y_train_labels)
我想在选择 k 个最佳功能后打印出选定的功能名称(文本),有什么办法吗?我只需要打印出选定的功能名称,也许我应该使用 CountVectorizer 代替?