NameError: name 'LdaModel' is not defined

3,719 views
Skip to first unread message

Christopher Grainger

unread,
Apr 17, 2014, 9:14:29 AM4/17/14
to gen...@googlegroups.com
So I've definitely entered:
from gensim import corpora, models, similarities

Everything works fine building the corpus until I try to actually estimate the model parameters.

lda = LdaModel(corpus,num_topics=100)

Then I get:
NameError: name 'LdaModel' is not defined 

I'm entering things line-by-line in iPython. Any idea why this might be the case? Once I've imported models, shouldn't LdaModel() be available? 

Rémi Bois

unread,
Apr 17, 2014, 9:28:49 AM4/17/14
to gen...@googlegroups.com
This is normal. You do not say where LdaModel is (in which module).

You should use

    lda = models.ldamodels.LdaModel(...)

You can check this page http://radimrehurek.com/gensim/models/ldamodel.html

This allows python to differentiate different functions/objects that come from different modules.

Rémi Bois

unread,
Apr 17, 2014, 9:30:34 AM4/17/14
to gen...@googlegroups.com
Oops I added an s to ldamodel

    lda = models.ldamodel.LdaModel(...)
Reply all
Reply to author
Forward
0 new messages