How To Specify Random_state In Lda Model For Topic Modelling
I read the gensim LDA model documentation about random_state which states that: random_state ({np.random.RandomState, int}, optional) – Either a randomState object or a seed to
Solution 1:
The mistake in your code is in here:
model=ldaModel(corpus=corpus, id2word=dictionary, num_topics=num_topics,
random_state)
You can't just pass the variable random_state
without specifying the label. Just passing the variable to the method with an int number means nothing to the ldaModel
method, since the method does not take positional parameter. The method takes named parameters. So it should be like this:
model=ldaModel(corpus=corpus, id2word=dictionary, num_topics=num_topics,
random_state = random_state)
I have an implementation of the LDA that uses LatentDirichletAllocation
from sklearn.decomposition
, and for the random_state
it takes an integer. Here is an example:
lda_model = LatentDirichletAllocation(n_components=10,
max_iter=10,
learning_method='online',
random_state=100,
batch_size=128,
evaluate_every = -1,
n_jobs = -1 )
Here is a good tutorial on how to implement and LDA
Post a Comment for "How To Specify Random_state In Lda Model For Topic Modelling"