Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4233#discussion_r24105728
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala ---
    @@ -65,6 +67,68 @@ class NaiveBayesModel private[mllib] (
       override def predict(testData: Vector): Double = {
         labels(brzArgmax(brzPi + brzTheta * testData.toBreeze))
       }
    +
    +  override def save(sc: SparkContext, path: String): Unit = {
    +    val data = NaiveBayesModel.SaveLoadV1_0.Data(labels, pi, theta)
    +    NaiveBayesModel.SaveLoadV1_0.save(sc, path, data)
    +  }
    +
    +  override protected def formatVersion: String = "1.0"
    +}
    +
    +object NaiveBayesModel extends Loader[NaiveBayesModel] {
    +
    +  private object SaveLoadV1_0 {
    +
    +    def thisFormatVersion = "1.0"
    +
    +    def thisClassName = 
"org.apache.spark.mllib.classification.NaiveBayesModel"
    +
    +    /** Model data for model import/export */
    +    case class Data(labels: Array[Double], pi: Array[Double], theta: 
Array[Array[Double]])
    +
    +    def save(sc: SparkContext, path: String, data: Data): Unit = {
    +      val sqlContext = new SQLContext(sc)
    +      import sqlContext._
    +
    +      // Create JSON metadata.
    +      val metadataRDD =
    +        sc.parallelize(Seq((thisClassName, 
thisFormatVersion))).toDataFrame("class", "version")
    --- End diff --
    
    Use `sc.parallelize(.., 1)` and remove `repartition(1)`.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to