WordVect को सहेजने में त्रुटि हुई,

from sklearn.feature_extraction.text import CountVectorizer
corpus = [
    'This is the first document.',
    'This document is the second document.',
    'And this is the third one.',
    'Is this the first document?',
]
vectorizer = CountVectorizer(ngram_range=()
X = vectorizer.fit_transform(corpus)

# Save The Vector 
np.savetxt('logvect.csv', X, delimiter=',')

त्रुटि मिली

----> 1 np.savetxt('logvect.csv', X, delimiter=',')

   1375         if X.ndim == 0 or X.ndim > 2:
   1376             raise ValueError(
-> 1377                 "Expected 1D or 2D array, got %dD array instead" % X.ndim)
   1378         elif X.ndim == 1:
   1379             # Common case -- 1d array of numbers

ValueError: Expected 1D or 2D array, got 0D array instead
0
user2458922 25 जुलाई 2019, 00:39

1 उत्तर

सबसे बढ़िया उत्तर

X.toarray() # गायब था

np.savetxt('logvect.csv', X.toarray(), delimiter=',')
0
user2458922 25 जुलाई 2019, 00:44