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

[GitHub] spark pull request: [SPARK-5988][MLlib] add save/load for PowerIte...

GitHub user yinxusen opened a pull request:

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

    [SPARK-5988][MLlib] add save/load for PowerIterationClusteringModel

    See JIRA issue [SPARK-5988](https://issues.apache.org/jira/browse/SPARK-5988).

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

    $ git pull https://github.com/yinxusen/spark SPARK-5988

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

    https://github.com/apache/spark/pull/5450.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 #5450
    
----
commit 63c3923d9a96ff267b9322615ac6f8ce40051a06
Author: Xusen Yin <yi...@gmail.com>
Date:   2015-04-10T08:13:34Z

    add save load for power iteration clustering

commit b1dd24cdbd731f180e2713544be7b0f0f92679e6
Author: Xusen Yin <yi...@gmail.com>
Date:   2015-04-10T08:56:02Z

    add test suite

----


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#issuecomment-92320638
  
      [Test build #30156 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/30156/consoleFull) for   PR 5450 at commit [`cb1ecfa`](https://github.com/apache/spark/commit/cb1ecfaec7523cf36b1466e27db6c3fc9e0fd873).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `  case class Assignment(id: Long, cluster: Int)`
    
     * This patch does not change any dependencies.


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#discussion_r28216448
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/PowerIterationClustering.scala ---
    @@ -38,7 +43,63 @@ import org.apache.spark.util.random.XORShiftRandom
     @Experimental
     class PowerIterationClusteringModel(
         val k: Int,
    -    val assignments: RDD[PowerIterationClustering.Assignment]) extends Serializable
    +    val assignments: RDD[PowerIterationClustering.Assignment]) extends Saveable with Serializable {
    +
    +  override def save(sc: SparkContext, path: String): Unit = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.save(sc, this, path)
    +  }
    +
    +  override protected def formatVersion: String = "1.0"
    +}
    +
    +object PowerIterationClusteringModel extends Loader[PowerIterationClusteringModel] {
    +  override def load(sc: SparkContext, path: String): PowerIterationClusteringModel = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.load(sc, path)
    +  }
    +
    +  private[clustering]
    +  object SaveLoadV1_0 {
    +
    +    private val thisFormatVersion = "1.0"
    +
    +    private[clustering]
    +    val thisClassName = "org.apache.spark.mllib.clustering.PowerIterationClusteringModel"
    +
    +    def save(sc: SparkContext, model: PowerIterationClusteringModel, path: String): Unit = {
    +      val sqlContext = new SQLContext(sc)
    +      import sqlContext.implicits._
    +
    +      val metadata = compact(render(
    +        ("class" -> thisClassName) ~ ("version" -> thisFormatVersion) ~ ("k" -> model.k)))
    +      sc.parallelize(Seq(metadata), 1).saveAsTextFile(Loader.metadataPath(path))
    +
    +      val dataRDD = model.assignments.map(x => (x.id, x.cluster)).toDF()
    --- End diff --
    
    `assignment.toDF()` should be sufficient and correct. Otherwise, the output column names would be "_1" and "_2".


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#issuecomment-91485201
  
      [Test build #30022 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/30022/consoleFull) for   PR 5450 at commit [`b1dd24c`](https://github.com/apache/spark/commit/b1dd24cdbd731f180e2713544be7b0f0f92679e6).


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#discussion_r28227026
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/PowerIterationClustering.scala ---
    @@ -38,7 +43,63 @@ import org.apache.spark.util.random.XORShiftRandom
     @Experimental
     class PowerIterationClusteringModel(
         val k: Int,
    -    val assignments: RDD[PowerIterationClustering.Assignment]) extends Serializable
    +    val assignments: RDD[PowerIterationClustering.Assignment]) extends Saveable with Serializable {
    +
    +  override def save(sc: SparkContext, path: String): Unit = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.save(sc, this, path)
    +  }
    +
    +  override protected def formatVersion: String = "1.0"
    +}
    +
    +object PowerIterationClusteringModel extends Loader[PowerIterationClusteringModel] {
    +  override def load(sc: SparkContext, path: String): PowerIterationClusteringModel = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.load(sc, path)
    +  }
    +
    +  private[clustering]
    +  object SaveLoadV1_0 {
    +
    +    private val thisFormatVersion = "1.0"
    +
    +    private[clustering]
    +    val thisClassName = "org.apache.spark.mllib.clustering.PowerIterationClusteringModel"
    +
    +    def save(sc: SparkContext, model: PowerIterationClusteringModel, path: String): Unit = {
    +      val sqlContext = new SQLContext(sc)
    +      import sqlContext.implicits._
    +
    +      val metadata = compact(render(
    +        ("class" -> thisClassName) ~ ("version" -> thisFormatVersion) ~ ("k" -> model.k)))
    +      sc.parallelize(Seq(metadata), 1).saveAsTextFile(Loader.metadataPath(path))
    +
    +      val dataRDD = model.assignments.map(x => (x.id, x.cluster)).toDF()
    --- End diff --
    
    It seems that changing `Assignment` into a case class has nothing wrong, so I change it. Otherwise I will write more code to check the schema, for the `Loader.checkSchema[]()`is not worked for an ordinary class.


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#issuecomment-91509149
  
      [Test build #30022 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/30022/consoleFull) for   PR 5450 at commit [`b1dd24c`](https://github.com/apache/spark/commit/b1dd24cdbd731f180e2713544be7b0f0f92679e6).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.
     * This patch does not change any dependencies.


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#issuecomment-92298524
  
      [Test build #30156 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/30156/consoleFull) for   PR 5450 at commit [`cb1ecfa`](https://github.com/apache/spark/commit/cb1ecfaec7523cf36b1466e27db6c3fc9e0fd873).


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#discussion_r28217008
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/PowerIterationClustering.scala ---
    @@ -38,7 +43,63 @@ import org.apache.spark.util.random.XORShiftRandom
     @Experimental
     class PowerIterationClusteringModel(
         val k: Int,
    -    val assignments: RDD[PowerIterationClustering.Assignment]) extends Serializable
    +    val assignments: RDD[PowerIterationClustering.Assignment]) extends Saveable with Serializable {
    +
    +  override def save(sc: SparkContext, path: String): Unit = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.save(sc, this, path)
    +  }
    +
    +  override protected def formatVersion: String = "1.0"
    +}
    +
    +object PowerIterationClusteringModel extends Loader[PowerIterationClusteringModel] {
    +  override def load(sc: SparkContext, path: String): PowerIterationClusteringModel = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.load(sc, path)
    +  }
    +
    +  private[clustering]
    +  object SaveLoadV1_0 {
    +
    +    private val thisFormatVersion = "1.0"
    +
    +    private[clustering]
    +    val thisClassName = "org.apache.spark.mllib.clustering.PowerIterationClusteringModel"
    +
    +    def save(sc: SparkContext, model: PowerIterationClusteringModel, path: String): Unit = {
    +      val sqlContext = new SQLContext(sc)
    +      import sqlContext.implicits._
    +
    +      val metadata = compact(render(
    +        ("class" -> thisClassName) ~ ("version" -> thisFormatVersion) ~ ("k" -> model.k)))
    +      sc.parallelize(Seq(metadata), 1).saveAsTextFile(Loader.metadataPath(path))
    +
    +      val dataRDD = model.assignments.map(x => (x.id, x.cluster)).toDF()
    --- End diff --
    
    `assignment` is not a case class, so we cannot call `toDF()` directly. Shall I change `Assignment` into a case class?


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#discussion_r28216481
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/PowerIterationClustering.scala ---
    @@ -38,7 +43,63 @@ import org.apache.spark.util.random.XORShiftRandom
     @Experimental
     class PowerIterationClusteringModel(
         val k: Int,
    -    val assignments: RDD[PowerIterationClustering.Assignment]) extends Serializable
    +    val assignments: RDD[PowerIterationClustering.Assignment]) extends Saveable with Serializable {
    +
    +  override def save(sc: SparkContext, path: String): Unit = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.save(sc, this, path)
    +  }
    +
    +  override protected def formatVersion: String = "1.0"
    +}
    +
    +object PowerIterationClusteringModel extends Loader[PowerIterationClusteringModel] {
    +  override def load(sc: SparkContext, path: String): PowerIterationClusteringModel = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.load(sc, path)
    +  }
    +
    +  private[clustering]
    +  object SaveLoadV1_0 {
    +
    +    private val thisFormatVersion = "1.0"
    +
    +    private[clustering]
    +    val thisClassName = "org.apache.spark.mllib.clustering.PowerIterationClusteringModel"
    +
    +    def save(sc: SparkContext, model: PowerIterationClusteringModel, path: String): Unit = {
    +      val sqlContext = new SQLContext(sc)
    +      import sqlContext.implicits._
    +
    +      val metadata = compact(render(
    +        ("class" -> thisClassName) ~ ("version" -> thisFormatVersion) ~ ("k" -> model.k)))
    +      sc.parallelize(Seq(metadata), 1).saveAsTextFile(Loader.metadataPath(path))
    +
    +      val dataRDD = model.assignments.map(x => (x.id, x.cluster)).toDF()
    +      dataRDD.saveAsParquetFile(Loader.dataPath(path))
    +    }
    +
    +    def load(sc: SparkContext, path: String): PowerIterationClusteringModel = {
    +      implicit val formats = DefaultFormats
    +      val sqlContext = new SQLContext(sc)
    +
    +      val (className, formatVersion, metadata) = Loader.loadMetadata(sc, path)
    +      assert(className == thisClassName)
    +      assert(formatVersion == thisFormatVersion)
    +
    +      val k = (metadata \ "k").extract[Int]
    +      val assignments = sqlContext.parquetFile(Loader.dataPath(path))
    +      Loader.checkSchema[(Long, Int)](assignments.schema)
    +
    +      val assignmentsRDD = assignments.map {
    +        case Row(id: Long, cluster: Int) => new PowerIterationClustering.Assignment(id, cluster)
    +      }
    +
    +      val realK = assignmentsRDD.map(_.cluster).distinct().collect().size
    --- End diff --
    
    This is expensive. Maybe we can ignore this check (or put it in the tests).


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#issuecomment-91509172
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/30022/
    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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#discussion_r28267250
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/PowerIterationClustering.scala ---
    @@ -38,7 +43,63 @@ import org.apache.spark.util.random.XORShiftRandom
     @Experimental
     class PowerIterationClusteringModel(
         val k: Int,
    -    val assignments: RDD[PowerIterationClustering.Assignment]) extends Serializable
    +    val assignments: RDD[PowerIterationClustering.Assignment]) extends Saveable with Serializable {
    +
    +  override def save(sc: SparkContext, path: String): Unit = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.save(sc, this, path)
    +  }
    +
    +  override protected def formatVersion: String = "1.0"
    +}
    +
    +object PowerIterationClusteringModel extends Loader[PowerIterationClusteringModel] {
    +  override def load(sc: SparkContext, path: String): PowerIterationClusteringModel = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.load(sc, path)
    +  }
    +
    +  private[clustering]
    +  object SaveLoadV1_0 {
    +
    +    private val thisFormatVersion = "1.0"
    +
    +    private[clustering]
    +    val thisClassName = "org.apache.spark.mllib.clustering.PowerIterationClusteringModel"
    +
    +    def save(sc: SparkContext, model: PowerIterationClusteringModel, path: String): Unit = {
    +      val sqlContext = new SQLContext(sc)
    +      import sqlContext.implicits._
    +
    +      val metadata = compact(render(
    +        ("class" -> thisClassName) ~ ("version" -> thisFormatVersion) ~ ("k" -> model.k)))
    +      sc.parallelize(Seq(metadata), 1).saveAsTextFile(Loader.metadataPath(path))
    +
    +      val dataRDD = model.assignments.map(x => (x.id, x.cluster)).toDF()
    --- End diff --
    
    That's okay. In general, the issue with case classes is that they are hard to extend. For example, changing `case class Assignment(id: Long, cluster: Int)` to `case class Assignment(id: Long, cluster: Int, confidence: Double)` breaks binary compatibility.


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#issuecomment-92320667
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/30156/
    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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#issuecomment-92459332
  
    LGTM. Merged into master. 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-5988][MLlib] add save/load for PowerIte...

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

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


---
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-5988][MLlib] add save/load for PowerIte...

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

    https://github.com/apache/spark/pull/5450#discussion_r28219216
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/PowerIterationClustering.scala ---
    @@ -38,7 +43,63 @@ import org.apache.spark.util.random.XORShiftRandom
     @Experimental
     class PowerIterationClusteringModel(
         val k: Int,
    -    val assignments: RDD[PowerIterationClustering.Assignment]) extends Serializable
    +    val assignments: RDD[PowerIterationClustering.Assignment]) extends Saveable with Serializable {
    +
    +  override def save(sc: SparkContext, path: String): Unit = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.save(sc, this, path)
    +  }
    +
    +  override protected def formatVersion: String = "1.0"
    +}
    +
    +object PowerIterationClusteringModel extends Loader[PowerIterationClusteringModel] {
    +  override def load(sc: SparkContext, path: String): PowerIterationClusteringModel = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.load(sc, path)
    +  }
    +
    +  private[clustering]
    +  object SaveLoadV1_0 {
    +
    +    private val thisFormatVersion = "1.0"
    +
    +    private[clustering]
    +    val thisClassName = "org.apache.spark.mllib.clustering.PowerIterationClusteringModel"
    +
    +    def save(sc: SparkContext, model: PowerIterationClusteringModel, path: String): Unit = {
    +      val sqlContext = new SQLContext(sc)
    +      import sqlContext.implicits._
    +
    +      val metadata = compact(render(
    +        ("class" -> thisClassName) ~ ("version" -> thisFormatVersion) ~ ("k" -> model.k)))
    +      sc.parallelize(Seq(metadata), 1).saveAsTextFile(Loader.metadataPath(path))
    +
    +      val dataRDD = model.assignments.map(x => (x.id, x.cluster)).toDF()
    --- End diff --
    
    Then call `toDF("id", "cluster")`.


---
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