Reputation: 235
I'm trying to use the TfidfVectorizer on a corpus but every time I end up with this error
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'
This is my code
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)
It works fine with CountVectorizer and the same error occurs if I try to transform the data using TfidfTransformer
Upvotes: 1
Views: 548
Reputation: 40149
Are you running 64 bit Windows? This might be caused by a known issue that has been recently fixed in the master branch.
Upvotes: 2