Repository: spark Updated Branches: refs/heads/master 5dc948e81 -> f301df37c
[SPARK-14152][ML][PYSPARK] MultilayerPerceptronClassifier supports save/load for Python API ## What changes were proposed in this pull request? ```MultilayerPerceptronClassifier``` supports save/load for Python API. ## How was this patch tested? doctest. cc mengxr jkbradley yinxusen Author: Yanbo Liang <yblia...@gmail.com> Closes #11952 from yanboliang/spark-14152. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/f301df37 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/f301df37 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/f301df37 Branch: refs/heads/master Commit: f301df37cb63aeecf48077ae56351538e6eeeeb7 Parents: 5dc948e Author: Yanbo Liang <yblia...@gmail.com> Authored: Wed Mar 30 15:47:01 2016 -0700 Committer: Joseph K. Bradley <jos...@databricks.com> Committed: Wed Mar 30 15:47:01 2016 -0700 ---------------------------------------------------------------------- python/pyspark/ml/classification.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/f301df37/python/pyspark/ml/classification.py ---------------------------------------------------------------------- diff --git a/python/pyspark/ml/classification.py b/python/pyspark/ml/classification.py index d51b80e..07cafa0 100644 --- a/python/pyspark/ml/classification.py +++ b/python/pyspark/ml/classification.py @@ -762,7 +762,7 @@ class NaiveBayesModel(JavaModel, JavaMLWritable, JavaMLReadable): @inherit_doc class MultilayerPerceptronClassifier(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, - HasMaxIter, HasTol, HasSeed): + HasMaxIter, HasTol, HasSeed, JavaMLWritable, JavaMLReadable): """ Classifier trainer based on the Multilayer Perceptron. Each layer has sigmoid activation function, output layer has softmax. @@ -792,6 +792,18 @@ class MultilayerPerceptronClassifier(JavaEstimator, HasFeaturesCol, HasLabelCol, |[0.0,0.0]| 0.0| +---------+----------+ ... + >>> mlp_path = temp_path + "/mlp" + >>> mlp.save(mlp_path) + >>> mlp2 = MultilayerPerceptronClassifier.load(mlp_path) + >>> mlp2.getBlockSize() + 1 + >>> model_path = temp_path + "/mlp_model" + >>> model.save(model_path) + >>> model2 = MultilayerPerceptronClassificationModel.load(model_path) + >>> model.layers == model2.layers + True + >>> model.weights == model2.weights + True .. versionadded:: 1.6.0 """ @@ -869,7 +881,7 @@ class MultilayerPerceptronClassifier(JavaEstimator, HasFeaturesCol, HasLabelCol, return self.getOrDefault(self.blockSize) -class MultilayerPerceptronClassificationModel(JavaModel): +class MultilayerPerceptronClassificationModel(JavaModel, JavaMLWritable, JavaMLReadable): """ Model fitted by MultilayerPerceptronClassifier. --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org