joezjh / labeled-lda-python Goto Github PK
View Code? Open in Web Editor NEWImplement of L-LDA Model(Labeled Latent Dirichlet Allocation Model) with python
License: MIT License
Implement of L-LDA Model(Labeled Latent Dirichlet Allocation Model) with python
License: MIT License
Halo Joe, Thank you again for the coding and your last answer to my question. If you are glad, I want to ask some questions about this code.
after iteration: 51, perplexity: 5931.100267564532
delta beta: 5.883340980101
before updating:
Labeled-LDA Model:
K = 61
M = 60120
T = 130755
WN = 4029682
LN = 60120
alpha = 0.01
eta = 0.001
perplexity = 5931.100267564532
after updating:
Labeled-LDA Model:
K = 61
M = 60121
T = 130763
WN = 4029695
LN = 60123
alpha = 0.01
eta = 0.001
perplexity = 5931.23254749438
iteration 52 sampling...
Traceback (most recent call last):
File "/Users/rr/opt/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Users/rr/opt/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/rr/labeled_lda/mt_llda.py", line 48, in train_model
llda_model.training(1)
File "/Users/rr/labeled_lda/labeled_lda.py", line 440, in training
self._gibbs_sample_training()
File "/Users/rr/labeled_lda/labeled_lda.py", line 272, in _gibbs_sample_training
sample_z = LldaModel._multinomial_sample(p_vector)
File "/Users/rr/labeled_lda/labeled_lda.py", line 218, in _multinomial_sample
return np.random.multinomial(1, p_vector).argmax()
File "mtrand.pyx", line 3863, in numpy.random.mtrand.RandomState.multinomial
File "common.pyx", line 323, in numpy.random.common.check_array_constraint
ValueError: pvals < 0, pvals > 1 or pvals contains NaNs
where the line 47 and line 48
File "/Users/rr/labeled_lda/mt_llda.py", line 48, in train_model
llda_model.training(1)
creates the object of labeled lda and sends it to training:
llda_model = llda.LldaModel(labeled_documents=labeled_documents, alpha_vector=0.01)
llda_model.training(1)
Dear,
First of all, thank you very much for your sharing a nice program.
I have a question related to the input labeled documents as follow
Each document has a following number, for example, labeled_documents = [("text" * 10, ['label_1]), ...],. In this case, what is 10 used for? How does it affect the training process? For example, if we change these values or even ignore them.
Thank you very much in advance!
Best regards,
Son.
Hai Joe, thankyou so much for the coding. I want to ask about common topic. What is the interpretation for that? I really appreciate your answer because right now I'm doing my undergraduate thesis using this code
Thank you very much for sharing your code.
When I download your example.py and run it, I found an error occured when I use
'''llda_model_new.load_model_from_dir(save_model_dir, load_derivative_properties=False)'''.
And here is the traceback:
'''
Traceback (most recent call last):
File "", line 1, in
runfile('D:/putong/taxiLDA/Labeled-LDA-Python-master/example/example.py', wdir='D:/putong/taxiLDA/Labeled-LDA-Python-master/example')
File "D:\ana\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "D:\ana\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/putong/taxiLDA/Labeled-LDA-Python-master/example/example.py", line 78, in
llda_model_new.load_model_from_dir(save_model_dir, load_derivative_properties=False)
File "..\model\labeled_lda.py", line 794, in load_model_from_dir
self._initialize_derivative_fields()
File "..\model\labeled_lda.py", line 126, in _initialize_derivative_fields
self.alpha_vector_Lambda = self.alpha_vector * self.Lambda
ValueError: operands could not be broadcast together with shapes (0,) (6,6)
'''
I think something goes wrong when the program loads and reads the model.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.