You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by viirya <gi...@git.apache.org> on 2015/02/10 10:48:10 UTC

[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

GitHub user viirya opened a pull request:

    https://github.com/apache/spark/pull/4501

    [SPARK-5714][Mllib] Refactor initial step of LDA to remove redundant operations

    The `initialState` of LDA performs several RDD operations that looks redundant. This pr tries to simplify these operations.
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/viirya/spark-1 sim_lda

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/4501.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #4501
    
----
commit 9af1487952c0f76b3370ea8467bdec0d945b2dfb
Author: Liang-Chi Hsieh <vi...@gmail.com>
Date:   2015-02-10T09:36:46Z

    Refactor initial step of LDA to remove redundant operations.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/4501#issuecomment-73679498
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/27193/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4501#discussion_r24435087
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/LDA.scala ---
    @@ -450,34 +450,25 @@ private[clustering] object LDA {
     
         // Create vertices.
         // Initially, we use random soft assignments of tokens to topics (random gamma).
    -    val edgesWithGamma: RDD[(Edge[TokenCount], TopicCounts)] =
    -      edges.mapPartitionsWithIndex { case (partIndex, partEdges) =>
    -        val random = new Random(partIndex + randomSeed)
    -        partEdges.map { edge =>
    -          // Create a random gamma_{wjk}
    -          (edge, normalize(BDV.fill[Double](k)(random.nextDouble()), 1.0))
    +    def createVertices(): RDD[(VertexId, TopicCounts)] = {
    +      val verticesTMP: RDD[(VertexId, TopicCounts)] =
    +        edges.mapPartitionsWithIndex { case (partIndex, partEdges) =>
    +          val random = new Random(partIndex + randomSeed)
    +          partEdges.flatMap { edge =>
    +            val gamma = normalize(BDV.fill[Double](k)(random.nextDouble()), 1.0)
    +            val sum = BDV.zeros[Double](k)
    +            brzAxpy(edge.attr, gamma, sum)
    +
    +            Seq((edge.srcId, sum), (edge.dstId, sum))
    +          }
             }
    -      }
    -    def createVertices(sendToWhere: Edge[TokenCount] => VertexId): RDD[(VertexId, TopicCounts)] = {
    -      val verticesTMP: RDD[(VertexId, (TokenCount, TopicCounts))] =
    -        edgesWithGamma.map { case (edge, gamma: TopicCounts) =>
    -          (sendToWhere(edge), (edge.attr, gamma))
    -        }
    -      verticesTMP.aggregateByKey(BDV.zeros[Double](k))(
    -        (sum, t) => {
    -          brzAxpy(t._1, t._2, sum)
    -          sum
    -        },
    -        (sum0, sum1) => {
    -          sum0 += sum1
    -        }
    -      )
    +      verticesTMP.reduceByKey((sum0, sum1) => { sum0 + sum1 })
    --- End diff --
    
    `reduceByKey(_ + _)`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/4501#issuecomment-73832866
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/27268/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on the pull request:

    https://github.com/apache/spark/pull/4501#issuecomment-73837186
  
    LGTM. Merged into master and branch-1.3. Thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/4501#issuecomment-73672230
  
      [Test build #27193 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/27193/consoleFull) for   PR 4501 at commit [`9af1487`](https://github.com/apache/spark/commit/9af1487952c0f76b3370ea8467bdec0d945b2dfb).
     * This patch merges cleanly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the pull request:

    https://github.com/apache/spark/pull/4501#issuecomment-73700334
  
    an unrelated failure...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/4501


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/4501#issuecomment-73828356
  
      [Test build #27268 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/27268/consoleFull) for   PR 4501 at commit [`4870fe4`](https://github.com/apache/spark/commit/4870fe4a0ebefad8074052857bbf9fee6a505464).
     * This patch merges cleanly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by mengxr <gi...@git.apache.org>.
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4501#discussion_r24435081
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/LDA.scala ---
    @@ -450,34 +450,25 @@ private[clustering] object LDA {
     
         // Create vertices.
         // Initially, we use random soft assignments of tokens to topics (random gamma).
    -    val edgesWithGamma: RDD[(Edge[TokenCount], TopicCounts)] =
    -      edges.mapPartitionsWithIndex { case (partIndex, partEdges) =>
    -        val random = new Random(partIndex + randomSeed)
    -        partEdges.map { edge =>
    -          // Create a random gamma_{wjk}
    -          (edge, normalize(BDV.fill[Double](k)(random.nextDouble()), 1.0))
    +    def createVertices(): RDD[(VertexId, TopicCounts)] = {
    +      val verticesTMP: RDD[(VertexId, TopicCounts)] =
    +        edges.mapPartitionsWithIndex { case (partIndex, partEdges) =>
    +          val random = new Random(partIndex + randomSeed)
    +          partEdges.flatMap { edge =>
    +            val gamma = normalize(BDV.fill[Double](k)(random.nextDouble()), 1.0)
    +            val sum = BDV.zeros[Double](k)
    +            brzAxpy(edge.attr, gamma, sum)
    --- End diff --
    
    This is `val sum = gamma * edge.attr`. We don't need `axpy` if the target vector does not exist.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/4501#issuecomment-73679489
  
      [Test build #27193 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/27193/consoleFull) for   PR 4501 at commit [`9af1487`](https://github.com/apache/spark/commit/9af1487952c0f76b3370ea8467bdec0d945b2dfb).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the pull request:

    https://github.com/apache/spark/pull/4501#issuecomment-73737525
  
    cc @jkbradley.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-5714][Mllib] Refactor initial step of L...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/4501#issuecomment-73832862
  
      [Test build #27268 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/27268/consoleFull) for   PR 4501 at commit [`4870fe4`](https://github.com/apache/spark/commit/4870fe4a0ebefad8074052857bbf9fee6a505464).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org