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

    https://github.com/apache/spark/pull/12573#discussion_r60676231
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/r/NaiveBayesWrapper.scala ---
    @@ -74,4 +83,41 @@ private[r] object NaiveBayesWrapper {
           .fit(data)
         new NaiveBayesWrapper(pipeline, labels, features)
       }
    +
    +  override def read: MLReader[NaiveBayesWrapper] = new 
NaiveBayesWrapperReader
    +
    +  override def load(path: String): NaiveBayesWrapper = super.load(path)
    +
    +  class NaiveBayesWrapperWriter(instance: NaiveBayesWrapper) extends 
MLWriter {
    +
    +    override protected def saveImpl(path: String): Unit = {
    +      val rMetadataPath = new Path(path, "rMetadata").toString
    +      val pipelinePath = new Path(path, "pipeline").toString
    +
    +      val rMetadata = ("class" -> instance.getClass.getName) ~
    +        ("labels" -> parse(compact(render(instance.labels.toSeq)))) ~
    +        ("features" -> parse(compact(render(instance.features.toSeq))))
    +      val rMetadataJson: String = compact(render(rMetadata))
    +      sc.parallelize(Seq(rMetadataJson), 1).saveAsTextFile(rMetadataPath)
    --- End diff --
    
    We use the same format as in ML pipelines. The output will be a folder 
instead of a single file. Maybe users can zip that folder if they want to send 
the model to someone else. Designing a new format is certainly beyond the scope 
of this PR.


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