lda2vec icon indicating copy to clipboard operation
lda2vec copied to clipboard

AxisError: axis -1 is out of bounds for array of dimension 0

Open Oliveche opened this issue 7 years ago • 3 comments

When I run preprocess.py,there is the following problem. How should I resolve it? Thanks very much!

runfile('D:/Python project/3Olive-lda2vec-master/examples/twenty_newsgroups/data/preprocess.py', wdir='D:/Python project/3Olive-lda2vec-master/examples/twenty_newsgroups/data') Traceback (most recent call last):

File "", line 1, in runfile('D:/Python project/3Olive-lda2vec-master/examples/twenty_newsgroups/data/preprocess.py', wdir='D:/Python project/3Olive-lda2vec-master/examples/twenty_newsgroups/data')

File "C:\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile execfile(filename, namespace)

File "C:\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/Python project/3Olive-lda2vec-master/examples/twenty_newsgroups/data/preprocess.py", line 35, in corpus.finalize()

File "D:\Python project\3Olive-lda2vec-master\lda2vec\corpus.py", line 155, in finalize self.keys_loose, self.keys_counts, n_keys = self._loose_keys_ordered()

File "D:\Python project\3Olive-lda2vec-master\lda2vec\corpus.py", line 104, in _loose_keys_ordered specials = np.sort(self.specials.values())

File "C:\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 822, in sort a.sort(axis=axis, kind=kind, order=order)

AxisError: axis -1 is out of bounds for array of dimension 0

Oliveche avatar Jan 10 '18 15:01 Oliveche

In this step,i change the python interpreter to 2.7,passed the error!

richzt avatar Jan 29 '18 11:01 richzt

The error is because of the type of self.specials.values() we have to convert it to Numpy array before sorting. In the function _loose_keys_ordered change the following line specials = np.sort(self.specials.values()) to -----> specials = np.sort(np.array([value for value in self.specials.values()]))

rajanalasailaja avatar Jan 25 '19 06:01 rajanalasailaja

when i change the following line , i'm getting this error : C:\Users\fathi\anaconda3\envs\lda2vec\lib\site-packages\lda2vec-0.1-py3.6.egg\lda2vec\corpus.py:422: FutureWarning: Support for multi-dimensional indexing (e.g. obj[:, None]) is deprecated and will be removed in a future version. Convert to a numpy array before indexing instead. how to fix this ??

fathia-ghribi avatar Feb 26 '21 15:02 fathia-ghribi