Github user felixcheung commented on a diff in the pull request:
https://github.com/apache/spark/pull/12573#discussion_r60675421
--- 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 --
should this support saving the model in a more compact format than text?
---
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]