You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by me...@apache.org on 2016/04/15 06:36:05 UTC
spark git commit: [SPARK-14374][ML][PYSPARK] PySpark ml GBTClassifier,
Regressor support export/import
Repository: spark
Updated Branches:
refs/heads/master 297ba3f1b -> b9613239d
[SPARK-14374][ML][PYSPARK] PySpark ml GBTClassifier, Regressor support export/import
## What changes were proposed in this pull request?
PySpark ml GBTClassifier, Regressor support export/import.
## How was this patch tested?
Doc test.
cc jkbradley
Author: Yanbo Liang <yb...@gmail.com>
Closes #12383 from yanboliang/spark-14374.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/b9613239
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/b9613239
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/b9613239
Branch: refs/heads/master
Commit: b9613239d303bc0f451233852c1eb1219a69875e
Parents: 297ba3f
Author: Yanbo Liang <yb...@gmail.com>
Authored: Thu Apr 14 21:36:03 2016 -0700
Committer: Xiangrui Meng <me...@databricks.com>
Committed: Thu Apr 14 21:36:03 2016 -0700
----------------------------------------------------------------------
python/pyspark/ml/classification.py | 17 +++++++++++++++--
python/pyspark/ml/regression.py | 17 +++++++++++++++--
2 files changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/b9613239/python/pyspark/ml/classification.py
----------------------------------------------------------------------
diff --git a/python/pyspark/ml/classification.py b/python/pyspark/ml/classification.py
index 922f806..6ef119a 100644
--- a/python/pyspark/ml/classification.py
+++ b/python/pyspark/ml/classification.py
@@ -739,7 +739,8 @@ class RandomForestClassificationModel(TreeEnsembleModels, JavaMLWritable, JavaML
@inherit_doc
class GBTClassifier(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, HasMaxIter,
- GBTParams, HasCheckpointInterval, HasStepSize, HasSeed):
+ GBTParams, HasCheckpointInterval, HasStepSize, HasSeed, JavaMLWritable,
+ JavaMLReadable):
"""
`http://en.wikipedia.org/wiki/Gradient_boosting Gradient-Boosted Trees (GBTs)`
learning algorithm for classification.
@@ -767,6 +768,18 @@ class GBTClassifier(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol
>>> test1 = sqlContext.createDataFrame([(Vectors.sparse(1, [0], [1.0]),)], ["features"])
>>> model.transform(test1).head().prediction
1.0
+ >>> gbtc_path = temp_path + "gbtc"
+ >>> gbt.save(gbtc_path)
+ >>> gbt2 = GBTClassifier.load(gbtc_path)
+ >>> gbt2.getMaxDepth()
+ 2
+ >>> model_path = temp_path + "gbtc_model"
+ >>> model.save(model_path)
+ >>> model2 = GBTClassificationModel.load(model_path)
+ >>> model.featureImportances == model2.featureImportances
+ True
+ >>> model.treeWeights == model2.treeWeights
+ True
.. versionadded:: 1.4.0
"""
@@ -831,7 +844,7 @@ class GBTClassifier(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol
return self.getOrDefault(self.lossType)
-class GBTClassificationModel(TreeEnsembleModels):
+class GBTClassificationModel(TreeEnsembleModels, JavaMLWritable, JavaMLReadable):
"""
Model fitted by GBTClassifier.
http://git-wip-us.apache.org/repos/asf/spark/blob/b9613239/python/pyspark/ml/regression.py
----------------------------------------------------------------------
diff --git a/python/pyspark/ml/regression.py b/python/pyspark/ml/regression.py
index c064fe5..3c78525 100644
--- a/python/pyspark/ml/regression.py
+++ b/python/pyspark/ml/regression.py
@@ -902,7 +902,8 @@ class RandomForestRegressionModel(TreeEnsembleModels, JavaMLWritable, JavaMLRead
@inherit_doc
class GBTRegressor(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, HasMaxIter,
- GBTParams, HasCheckpointInterval, HasStepSize, HasSeed):
+ GBTParams, HasCheckpointInterval, HasStepSize, HasSeed, JavaMLWritable,
+ JavaMLReadable):
"""
`http://en.wikipedia.org/wiki/Gradient_boosting Gradient-Boosted Trees (GBTs)`
learning algorithm for regression.
@@ -925,6 +926,18 @@ class GBTRegressor(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol,
>>> test1 = sqlContext.createDataFrame([(Vectors.sparse(1, [0], [1.0]),)], ["features"])
>>> model.transform(test1).head().prediction
1.0
+ >>> gbtr_path = temp_path + "gbtr"
+ >>> gbt.save(gbtr_path)
+ >>> gbt2 = GBTRegressor.load(gbtr_path)
+ >>> gbt2.getMaxDepth()
+ 2
+ >>> model_path = temp_path + "gbtr_model"
+ >>> model.save(model_path)
+ >>> model2 = GBTRegressionModel.load(model_path)
+ >>> model.featureImportances == model2.featureImportances
+ True
+ >>> model.treeWeights == model2.treeWeights
+ True
.. versionadded:: 1.4.0
"""
@@ -989,7 +1002,7 @@ class GBTRegressor(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol,
return self.getOrDefault(self.lossType)
-class GBTRegressionModel(TreeEnsembleModels):
+class GBTRegressionModel(TreeEnsembleModels, JavaMLWritable, JavaMLReadable):
"""
Model fitted by GBTRegressor.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org