{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/36156091","id":36156091,"diff_hunk":"@@ -267,32 +272,35 @@ class LocalLDAModel private[clustering] (\n     // by topic (columns of lambda)\n     val Elogbeta = LDAUtils.dirichletExpectation(lambda.t).t\n \n-    var score = documents.filter(_._2.numNonzeros > 0).map { case (id: Long, termCounts: Vector) =>\n-      var docScore = 0.0D\n-      val (gammad: BDV[Double], _) = OnlineLDAOptimizer.variationalTopicInference(\n-        termCounts, exp(Elogbeta), brzAlpha, gammaShape, k)\n-      val Elogthetad: BDV[Double] = LDAUtils.dirichletExpectation(gammad)\n-\n-      // E[log p(doc | theta, beta)]\n-      termCounts.foreachActive { case (idx, count) =>\n-        docScore += count * LDAUtils.logSumExp(Elogthetad + Elogbeta(idx, ::).t)\n-      }\n-      // E[log p(theta | alpha) - log q(theta | gamma)]; assumes alpha is a vector\n-      docScore += sum((brzAlpha - gammad) :* Elogthetad)\n-      docScore += sum(lgamma(gammad) - lgamma(brzAlpha))\n-      docScore += lgamma(sum(brzAlpha)) - lgamma(sum(gammad))\n-\n-      docScore\n-    }.sum()\n+    // Sum bound components for each document:\n+    //  component for prob(tokens) + component for prob(document-topic distribution)","path":"mllib/src/main/scala/org/apache/spark/mllib/clustering/LDAModel.scala","position":83,"original_position":83,"commit_id":"97947aa4a37d508d43e5f89fd34f6dab6013afbf","original_commit_id":"97947aa4a37d508d43e5f89fd34f6dab6013afbf","user":{"login":"jkbradley","id":5084283,"avatar_url":"https://avatars.githubusercontent.com/u/5084283?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbradley","html_url":"https://github.com/jkbradley","followers_url":"https://api.github.com/users/jkbradley/followers","following_url":"https://api.github.com/users/jkbradley/following{/other_user}","gists_url":"https://api.github.com/users/jkbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbradley/subscriptions","organizations_url":"https://api.github.com/users/jkbradley/orgs","repos_url":"https://api.github.com/users/jkbradley/repos","events_url":"https://api.github.com/users/jkbradley/events{/privacy}","received_events_url":"https://api.github.com/users/jkbradley/received_events","type":"User","site_admin":false},"body":"Yes, it was meant to be clearer...hm","created_at":"2015-08-04T04:12:58Z","updated_at":"2015-08-04T04:12:58Z","html_url":"https://github.com/apache/spark/pull/7916#discussion_r36156091","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/7916","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/36156091"},"html":{"href":"https://github.com/apache/spark/pull/7916#discussion_r36156091"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/7916"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/7916","id":41525367,"html_url":"https://github.com/apache/spark/pull/7916","diff_url":"https://github.com/apache/spark/pull/7916.diff","patch_url":"https://github.com/apache/spark/pull/7916.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/7916","number":7916,"state":"open","locked":false,"title":"[SPARK-9582] [ml] Clarified log likelihood for LDA models","user":{"login":"jkbradley","id":5084283,"avatar_url":"https://avatars.githubusercontent.com/u/5084283?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbradley","html_url":"https://github.com/jkbradley","followers_url":"https://api.github.com/users/jkbradley/followers","following_url":"https://api.github.com/users/jkbradley/following{/other_user}","gists_url":"https://api.github.com/users/jkbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbradley/subscriptions","organizations_url":"https://api.github.com/users/jkbradley/orgs","repos_url":"https://api.github.com/users/jkbradley/repos","events_url":"https://api.github.com/users/jkbradley/events{/privacy}","received_events_url":"https://api.github.com/users/jkbradley/received_events","type":"User","site_admin":false},"body":"Small cleanups to recent LDA additions and docs.\r\n\r\nCC: @feynmanliang ","created_at":"2015-08-04T00:58:42Z","updated_at":"2015-08-04T04:12:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b0e3a18a286ec60cdf8e8662a22f4005fc5a3d18","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/7916/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/7916/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/7916/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/97947aa4a37d508d43e5f89fd34f6dab6013afbf","head":{"label":"jkbradley:lda-cleanups","ref":"lda-cleanups","sha":"97947aa4a37d508d43e5f89fd34f6dab6013afbf","user":{"login":"jkbradley","id":5084283,"avatar_url":"https://avatars.githubusercontent.com/u/5084283?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbradley","html_url":"https://github.com/jkbradley","followers_url":"https://api.github.com/users/jkbradley/followers","following_url":"https://api.github.com/users/jkbradley/following{/other_user}","gists_url":"https://api.github.com/users/jkbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbradley/subscriptions","organizations_url":"https://api.github.com/users/jkbradley/orgs","repos_url":"https://api.github.com/users/jkbradley/repos","events_url":"https://api.github.com/users/jkbradley/events{/privacy}","received_events_url":"https://api.github.com/users/jkbradley/received_events","type":"User","site_admin":false},"repo":{"id":19877817,"name":"spark","full_name":"jkbradley/spark","owner":{"login":"jkbradley","id":5084283,"avatar_url":"https://avatars.githubusercontent.com/u/5084283?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbradley","html_url":"https://github.com/jkbradley","followers_url":"https://api.github.com/users/jkbradley/followers","following_url":"https://api.github.com/users/jkbradley/following{/other_user}","gists_url":"https://api.github.com/users/jkbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbradley/subscriptions","organizations_url":"https://api.github.com/users/jkbradley/orgs","repos_url":"https://api.github.com/users/jkbradley/repos","events_url":"https://api.github.com/users/jkbradley/events{/privacy}","received_events_url":"https://api.github.com/users/jkbradley/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jkbradley/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/jkbradley/spark","forks_url":"https://api.github.com/repos/jkbradley/spark/forks","keys_url":"https://api.github.com/repos/jkbradley/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jkbradley/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jkbradley/spark/teams","hooks_url":"https://api.github.com/repos/jkbradley/spark/hooks","issue_events_url":"https://api.github.com/repos/jkbradley/spark/issues/events{/number}","events_url":"https://api.github.com/repos/jkbradley/spark/events","assignees_url":"https://api.github.com/repos/jkbradley/spark/assignees{/user}","branches_url":"https://api.github.com/repos/jkbradley/spark/branches{/branch}","tags_url":"https://api.github.com/repos/jkbradley/spark/tags","blobs_url":"https://api.github.com/repos/jkbradley/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jkbradley/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jkbradley/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/jkbradley/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jkbradley/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/jkbradley/spark/languages","stargazers_url":"https://api.github.com/repos/jkbradley/spark/stargazers","contributors_url":"https://api.github.com/repos/jkbradley/spark/contributors","subscribers_url":"https://api.github.com/repos/jkbradley/spark/subscribers","subscription_url":"https://api.github.com/repos/jkbradley/spark/subscription","commits_url":"https://api.github.com/repos/jkbradley/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/jkbradley/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/jkbradley/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/jkbradley/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/jkbradley/spark/contents/{+path}","compare_url":"https://api.github.com/repos/jkbradley/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jkbradley/spark/merges","archive_url":"https://api.github.com/repos/jkbradley/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jkbradley/spark/downloads","issues_url":"https://api.github.com/repos/jkbradley/spark/issues{/number}","pulls_url":"https://api.github.com/repos/jkbradley/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/jkbradley/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/jkbradley/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jkbradley/spark/labels{/name}","releases_url":"https://api.github.com/repos/jkbradley/spark/releases{/id}","created_at":"2014-05-17T03:51:41Z","updated_at":"2015-05-08T20:04:51Z","pushed_at":"2015-08-04T01:42:00Z","git_url":"git://github.com/jkbradley/spark.git","ssh_url":"git@github.com:jkbradley/spark.git","clone_url":"https://github.com/jkbradley/spark.git","svn_url":"https://github.com/jkbradley/spark","homepage":null,"size":117822,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"1633d0a2612d94151f620c919425026150e69ae1","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-08-04T04:12:06Z","pushed_at":"2015-08-04T04:08:40Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":1631177,"stargazers_count":4954,"watchers_count":4954,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4493,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":330,"forks":4493,"open_issues":330,"watchers":4954,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/7916"},"html":{"href":"https://github.com/apache/spark/pull/7916"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/7916"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/7916/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/7916/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/7916/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/97947aa4a37d508d43e5f89fd34f6dab6013afbf"}}}}