cemoody / lda2vec

MIT License
3.15k stars 628 forks source link

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

Open Oliveche opened 6 years ago

Oliveche commented 6 years ago

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

richzt commented 6 years ago

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

rajanalasailaja commented 5 years ago

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()]))

fathia-ghribi commented 3 years ago

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 ??