ericproffitt / TopicModelsVB.jl

A Julia package for variational Bayesian topic modeling.
Other
81 stars 8 forks source link

Test_model.Elbo, is it the right. #37

Closed ValeriiBaidin closed 3 years ago

ValeriiBaidin commented 3 years ago

I wonder about Model.Elbo. Should it be the same, after predict(test_corp, train_model), if test_corp are equal train_corp. So I've just predicted model on the same corpus. Alpha, Beta, Elogtheta are the same. I've tested it and I could get the same elbo. I also use update_elbo(model) function at the end of predict() function.

Would you check my understanding? Why I can't get the same elbo?

I really appreciate any help you can provide.

ericproffitt commented 3 years ago

Hi Valerii,

So only the essential variables of the input model are transferred over to the output model. Nonessential variables (such as the ELBO) are not transferred. In fact it doesn't, in general, make sense to transfer the ELBO, since most of the time the train and test corpora will be different.

The output model can be trained if you'd like, however its primary purpose is to be a container for topic information. Do you have a particular use case in mind where you need to transfer all the model data from the input model to the output model?

ValeriiBaidin commented 3 years ago

Hi. Thank you for your answer.

I need some measure of model quality that I can use on testing data. So I think I can use Elbo for this purpose.

I've added to the end of function predict at modulutils.jl, update_elbo!(model). Can I do it?

What do you think about it? Thank you in advance.

ericproffitt commented 3 years ago

Sure, that should be fine.

Actually on second thought, this won't work as is.

You will also need to set all the _old global variables equal to their regular counterparts, e.g. for LDA you would need to set

model.beta_old = copy(train_model.beta)
ValeriiBaidin commented 3 years ago

thank you, it's work, If it is possible, would you add these two lines in the master?

Thank you so much.!!

ericproffitt commented 3 years ago

I may consider it, however updating the ELBO can be time consuming for large models, so for now I'm going to leave it to the user to do manually if they so desire.