我试图在语料库上使用TfidfVectorizer,但每次我都会遇到此错误
File "sparsefuncs.pyx", line 117, in sklearn.utils.sparsefuncs.inplace_csr_row_normalize_l2 (sklearn\utils\sparsefuncs.c:2328)
ValueError: Buffer dtype mismatch, expected 'int' but got 'long long'
这是我的代码
corpus = []
testCorpus = []
trainType = []
testType = []
with open("stone_sku.csv") as f:
cr = csv.DictReader(f)
for row in cr:
corpus.append(row['sku'])
trainType.append(row['sku'])
with open("stone_sku.csv") as f:
crTest = csv.DictReader(f)
for row in crTest:
testCorpus.append(row['sku'])
testType.append(row['sku'])
cv = TfidfVectorizer(min_df=1, analyzer='char', ngram_range=(2,3))
trainCounts = cv.fit_transform(corpus)
它适用于CountVectorizer,如果我尝试使用TfidfTransformer转换数据,则会出现同样的错误
答案 0 :(得分:2)
你在运行64位Windows吗?这可能是由最近在主分支中修复的已知问题引起的。