0
我在机器学习之前做了一些文本预处理。我有两个特点(熊猫系列) - abstract
和title
- 并使用以下功能对数据进行预处理(给人一种numpy的阵列,其中每行包含一个训练样本的特征):TF-IDF NLTK预处理后的权重
def preprocessText(data):
stemmer = nltk.stem.porter.PorterStemmer()
preprocessed = []
for each in data:
tokens = nltk.word_tokenize(each.lower().translate(xlate))
filtered = [word for word in tokens if word not in stopwords]
preprocessed.append([stemmer.stem(item) for item in filtered])
print(Counter(sum([list(x) for x in preprocessed], [])))
return np.array(preprocessed)
我现在需要使用TF-IDF来加权特征 - 我该怎么做?