【发布时间】:2021-12-17 07:35:18
【问题描述】:
dfff 是一个已经被标记化的数据帧,将用于通过 tfidfvectorizer 转换为 tf-idf。
这是 dfff 示例:
[![在此处输入图片描述][1]][1]
然后我创建一个 tfidfvectorizer 一个
tfidf_vecer2 = TfidfVectorizer(analyzer = 'word', token_pattern=None)
然后我运行了这段代码:
tfidf_vectorr= tfidf_vecer2.fit_transform(dfff)
tfidf_array = np.array(tfidf_vectorr.todense())
突然,TypeError 作为输出发生了,我仍然无法弄清楚。 我尝试使用列表而不是数据框,但它仍然出错。这是一个输出:
TypeError: 第一个参数必须是字符串或编译模式
【问题讨论】:
标签: python scikit-learn nlp tf-idf tfidfvectorizer