How to obtain the topic score in LSI model of Gensim?

1.5k Views Asked by At

I have been using LsiModel in gensim for modelling topics from a corpus of 10000 mails. I am able to get the words and word scores for each topic and store them in a file. I have tried using print_topics() and show_topics() but both return only the words & score associated with those words. But I also need the topic score that it outputs to the log file, I want those values in a variable. Like for this example log output below:

2010-11-03 16:08:27,602 : INFO : topic #0(200.990): -0.475*"delete" + -0.383*"deletion" + -0.275*"debate" + -0.223*"comments" + -0.220*"edits" + -0.213*"modify" + -0.208*"appropriate" + -0.194*"subsequent" + -0.155*"wp" + -0.117*"notability"
2010-11-03 16:08:27,626 : INFO : topic #1(143.129): -0.320*"diff" + -0.305*"link" + -0.199*"image" + -0.171*"www" + -0.162*"user" + 0.149*"delete" + -0.147*"undo" + -0.144*"contribs" + -0.122*"album" + 0.113*"deletion"
2010-11-03 16:08:27,651 : INFO : topic #2(135.665): -0.437*"diff" + -0.400*"link" + -0.202*"undo" + -0.192*"user" + -0.182*"www" + -0.176*"contribs" + 0.168*"image" + -0.109*"added" + 0.106*"album" + 0.097*"copyright"
2010-11-03 16:08:27,677 : INFO : topic #3(125.027): -0.354*"image" + 0.239*"age" + 0.218*"median" + -0.213*"copyright" + 0.204*"population" + -0.195*"fair" + 0.195*"income" + 0.167*"census" + 0.165*"km" + 0.162*"households"
2010-11-03 16:08:27,701 : INFO : topic #4(116.927): -0.307*"image" + 0.195*"players" + 0.184*"median" + -0.184*"copyright" + -0.181*"age" + -0.167*"fair" + -0.162*"income" + -0.151*"population" + -0.136*"households" + -0.134*"census"

I need these score in a variable.

topic #0 : 200.990 
topic #1 : 143.129
topic #2 : 135.665
topic #3 : 125.027
topic #4 : 116.927

Is there any method in the package to get these outputs? Please help.

1

There are 1 best solutions below

0
On

Yes. These are the singular values associated with each factor.

You can get them from model.projection.s.