Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

(v3.4.1) IndexError: index 46308 is out of bounds for axis 1 with size 17797 #253

Open
ooker777 opened this issue May 31, 2023 · 3 comments
Assignees

Comments

@ooker777
Copy link

ooker777 commented May 31, 2023

I get

IndexError: index 46308 is out of bounds for axis 1 with size 17797

I'm using pyLDAvis v3.4.1 on Python 3.10.10 on Windows. Here is the full code:

import pickle
from gensim import models
import pyLDAvis.gensim

id2word = pickle.load(open('../data/id2word.pkl','rb'))
cv_vecs = pickle.load(open('../data/cv_vecs.pkl','rb'))
cv_corpus = pickle.load(open('../data/cv_corpus.pkl','rb'))
lda =  models.LdaModel.load('../data/gensim_lda.model')

viz = pyLDAvis.gensim.prepare(topic_model=lda, corpus=cv_corpus, dictionary=id2word, mds='mmds')

You can check the input files here

@msusol
Copy link
Collaborator

msusol commented Apr 24, 2024

Correcting the code for v 3.4.1: pyLDAvis.gensim -> pyLDAvis.gensim_models

import pickle
from gensim import models
#import pyLDAvis.gensim
import pyLDAvis.gensim_models as gensimvis

id2word = pickle.load(open('../data/id2word.pkl','rb'))
cv_vecs = pickle.load(open('../data/cv_vecs.pkl','rb'))
cv_corpus = pickle.load(open('../data/cv_corpus.pkl','rb'))
lda =  models.LdaModel.load('../data/gensim_lda.model')

#viz = pyLDAvis.gensim.prepare(topic_model=lda, corpus=cv_corpus, dictionary=id2word, mds='mmds')
viz = gensimvis.prepare(topic_model=lda, corpus=cv_corpus, dictionary=id2word, mds='mmds')

Do you still get the same error?

@msusol msusol self-assigned this Apr 24, 2024
@msusol
Copy link
Collaborator

msusol commented Apr 30, 2024

FYI /data/cv_vecs.pkl is not present in zip file (if needed)

I get an error trying to evaluate using your model

Traceback (most recent call last):
  File "/Users/marksusol/DataScience/GitHub/pyLDAvis/issue253data/issue253.py", line 9, in <module>
    lda =  models.LdaModel.load('./data/gensim_lda.model')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/marksusol/DataScience/GitHub/pyLDAvis/venv/lib/python3.11/site-packages/gensim/models/ldamodel.py", line 1663, in load
    result = super(LdaModel, cls).load(fname, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/marksusol/DataScience/GitHub/pyLDAvis/venv/lib/python3.11/site-packages/gensim/utils.py", line 487, in load
    obj._load_specials(fname, mmap, compress, subname)
  File "/Users/marksusol/DataScience/GitHub/pyLDAvis/venv/lib/python3.11/site-packages/gensim/utils.py", line 529, in _load_specials
    val = np.load(subname(fname, attrib), mmap_mode=mmap)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/marksusol/DataScience/GitHub/pyLDAvis/venv/lib/python3.11/site-packages/numpy/lib/npyio.py", line 427, in load
    fid = stack.enter_context(open(os_fspath(file), "rb"))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: './data/gensim_lda.model.expElogbeta.npy'
``

@msusol
Copy link
Collaborator

msusol commented Apr 30, 2024

Can't reproduce, consider stale.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants