Repository: spark
Updated Branches:
  refs/heads/branch-2.0 63fd3301c -> dff3d75db


[SPARK-16130][ML] model loading backward compatibility for 
ml.classfication.LogisticRegression

## What changes were proposed in this pull request?
jira: https://issues.apache.org/jira/browse/SPARK-16130
model loading backward compatibility for ml.classfication.LogisticRegression

## How was this patch tested?
existing ut and manual test for loading old models.

Author: Yuhao Yang <hhb...@gmail.com>

Closes #13841 from hhbyyh/lrcomp.

(cherry picked from commit 60398dabc50d402bbab4190fbe94ebed6d3a48dc)
Signed-off-by: Xiangrui Meng <m...@databricks.com>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/dff3d75d
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/dff3d75d
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/dff3d75d

Branch: refs/heads/branch-2.0
Commit: dff3d75db4c2848a43ed8a3084c75f38c93138af
Parents: 63fd330
Author: Yuhao Yang <hhb...@gmail.com>
Authored: Thu Jun 23 11:00:00 2016 -0700
Committer: Xiangrui Meng <m...@databricks.com>
Committed: Thu Jun 23 11:00:06 2016 -0700

----------------------------------------------------------------------
 .../spark/ml/classification/LogisticRegression.scala      | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/dff3d75d/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
----------------------------------------------------------------------
diff --git 
a/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
 
b/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
index be69d46..9c9f5ce 100644
--- 
a/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
+++ 
b/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
@@ -674,12 +674,12 @@ object LogisticRegressionModel extends 
MLReadable[LogisticRegressionModel] {
 
       val dataPath = new Path(path, "data").toString
       val data = sparkSession.read.format("parquet").load(dataPath)
-        .select("numClasses", "numFeatures", "intercept", 
"coefficients").head()
+
       // We will need numClasses, numFeatures in the future for multinomial 
logreg support.
-      // val numClasses = data.getInt(0)
-      // val numFeatures = data.getInt(1)
-      val intercept = data.getDouble(2)
-      val coefficients = data.getAs[Vector](3)
+      val Row(numClasses: Int, numFeatures: Int, intercept: Double, 
coefficients: Vector) =
+        MLUtils.convertVectorColumnsToML(data, "coefficients")
+          .select("numClasses", "numFeatures", "intercept", "coefficients")
+          .head()
       val model = new LogisticRegressionModel(metadata.uid, coefficients, 
intercept)
 
       DefaultParamsReader.getAndSetParams(model, metadata)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to