【发布时间】:2021-05-23 07:59:09
【问题描述】:
MemoryError:无法为形状为 (50000, 164921) 且数据类型为 float64 的数组分配 61.4 GiB
tfidf = TfidfVectorizer(analyzer=remove_stopwords)
X = tfidf.fit_transform(df['lemmatize'])
print(X.shape)
Output : (50000, 164921)
现在,内存错误来了
df = pd.DataFrame(X.toarray(), columns=tfidf.get_feature_names())
MemoryError: 无法为形状为 (50000, 164921) 且数据类型为 float64 的数组分配 61.4 GiB
【问题讨论】:
-
您可以设置
TfidfVectorizer的参数来处理内存,例如max_features。
标签: python pandas nlp vectorization tf-idf