{"action":"created","issue":{"url":"https://api.github.com/repos/piskvorky/gensim/issues/683","repository_url":"https://api.github.com/repos/piskvorky/gensim","labels_url":"https://api.github.com/repos/piskvorky/gensim/issues/683/labels{/name}","comments_url":"https://api.github.com/repos/piskvorky/gensim/issues/683/comments","events_url":"https://api.github.com/repos/piskvorky/gensim/issues/683/events","html_url":"https://github.com/piskvorky/gensim/issues/683","id":150835101,"number":683,"title":"API call for Topic Distribution of words.","user":{"login":"bhargavvader","id":8374816,"avatar_url":"https://avatars.githubusercontent.com/u/8374816?v=3","gravatar_id":"","url":"https://api.github.com/users/bhargavvader","html_url":"https://github.com/bhargavvader","followers_url":"https://api.github.com/users/bhargavvader/followers","following_url":"https://api.github.com/users/bhargavvader/following{/other_user}","gists_url":"https://api.github.com/users/bhargavvader/gists{/gist_id}","starred_url":"https://api.github.com/users/bhargavvader/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhargavvader/subscriptions","organizations_url":"https://api.github.com/users/bhargavvader/orgs","repos_url":"https://api.github.com/users/bhargavvader/repos","events_url":"https://api.github.com/users/bhargavvader/events{/privacy}","received_events_url":"https://api.github.com/users/bhargavvader/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/piskvorky/gensim/labels/medium%20difficult","name":"medium difficult","color":"00d000"},{"url":"https://api.github.com/repos/piskvorky/gensim/labels/wishlist","name":"wishlist","color":"d7e102"}],"state":"open","locked":false,"assignee":{"login":"tmylk","id":1261528,"avatar_url":"https://avatars.githubusercontent.com/u/1261528?v=3","gravatar_id":"","url":"https://api.github.com/users/tmylk","html_url":"https://github.com/tmylk","followers_url":"https://api.github.com/users/tmylk/followers","following_url":"https://api.github.com/users/tmylk/following{/other_user}","gists_url":"https://api.github.com/users/tmylk/gists{/gist_id}","starred_url":"https://api.github.com/users/tmylk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmylk/subscriptions","organizations_url":"https://api.github.com/users/tmylk/orgs","repos_url":"https://api.github.com/users/tmylk/repos","events_url":"https://api.github.com/users/tmylk/events{/privacy}","received_events_url":"https://api.github.com/users/tmylk/received_events","type":"User","site_admin":false},"milestone":null,"comments":23,"created_at":"2016-04-25T12:00:08Z","updated_at":"2016-06-09T12:38:58Z","closed_at":null,"body":"As discussed [here](https://groups.google.com/forum/#!topic/gensim/hgjQPqP-0JU) and [here](https://groups.google.com/forum/#!searchin/gensim/how$20to$20print$20topic$20distribution%7Csort:relevance/gensim/Vv7SSC8HR8k/b4knKmArX0MJ) in the mailing list, there is no current way to find the a `topic index` for a word - i.e the topic a word belongs to - basically the distribution over all topics for a single word. \r\n\r\nAs @piskvorky mentioned in the second link, the ideal way now is:\r\n\r\n\"With variational inference LDA (such as the implementation in gensim), you can get the per-word topic distribution from `phi`, one of the variational parameters. When you call `lda.inference()` with `collect_sstats=True`, it will return a 2-tuple of (gamma, sufficient statistics). In your single-word case, these sufficient statistics directly correspond to (already normalized) phi, so you can read the word topics directly off of that.\"\r\n\r\n[This](https://groups.google.com/forum/#!topic/gensim/Qoj7Agkx3qE) also talks about the same, and describes the problem/what is needed in simpler words.\r\n\r\nI'll open a PR soon for this, and would like to take suggestions- would it be as a method in the `ldamodel` class, with just takes a word as a parameter, which uses VB internal parameters and gives back the topic and probability, or is there a different approach? "},"comment":{"url":"https://api.github.com/repos/piskvorky/gensim/issues/comments/224882099","html_url":"https://github.com/piskvorky/gensim/issues/683#issuecomment-224882099","issue_url":"https://api.github.com/repos/piskvorky/gensim/issues/683","id":224882099,"user":{"login":"graychan","id":7442809,"avatar_url":"https://avatars.githubusercontent.com/u/7442809?v=3","gravatar_id":"","url":"https://api.github.com/users/graychan","html_url":"https://github.com/graychan","followers_url":"https://api.github.com/users/graychan/followers","following_url":"https://api.github.com/users/graychan/following{/other_user}","gists_url":"https://api.github.com/users/graychan/gists{/gist_id}","starred_url":"https://api.github.com/users/graychan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graychan/subscriptions","organizations_url":"https://api.github.com/users/graychan/orgs","repos_url":"https://api.github.com/users/graychan/repos","events_url":"https://api.github.com/users/graychan/events{/privacy}","received_events_url":"https://api.github.com/users/graychan/received_events","type":"User","site_admin":false},"created_at":"2016-06-09T12:38:58Z","updated_at":"2016-06-09T12:38:58Z","body":"@bhargavvader ,@tmylk, and @piskvorky , thanks a lot for the clarification and quick reply. \r\n\r\nEariler, @bhargavvader pointed out,\r\n\r\n> Something like - get_document_topics(per_word_topics=True, per_word_phi_values=True)\r\n\r\nSo, can [get_document_topics(...)](https://github.com/bhargavvader/gensim/blob/0371aae00b729abe5e902a4fe2f1d74baeaedae6/gensim/models/ldamodel.py#L886)  be revised to return phi_values then? If two parameters `per_word_topics` and `per_word_phi_values` are too bloated, perhaps, the function can be made to just return the list of `(word_type, phi_values)`, and let users retrieve topic_id or phi_value by themselves? \r\n\r\n"}}
{"actor":{"display_login":"graychan"}}