Skip to content

Commit 60398da

Browse files
hhbyyhmengxr
authored andcommitted
[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 <[email protected]> Closes apache#13841 from hhbyyh/lrcomp.
1 parent d85bb10 commit 60398da

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -674,12 +674,12 @@ object LogisticRegressionModel extends MLReadable[LogisticRegressionModel] {
674674

675675
val dataPath = new Path(path, "data").toString
676676
val data = sparkSession.read.format("parquet").load(dataPath)
677-
.select("numClasses", "numFeatures", "intercept", "coefficients").head()
677+
678678
// We will need numClasses, numFeatures in the future for multinomial logreg support.
679-
// val numClasses = data.getInt(0)
680-
// val numFeatures = data.getInt(1)
681-
val intercept = data.getDouble(2)
682-
val coefficients = data.getAs[Vector](3)
679+
val Row(numClasses: Int, numFeatures: Int, intercept: Double, coefficients: Vector) =
680+
MLUtils.convertVectorColumnsToML(data, "coefficients")
681+
.select("numClasses", "numFeatures", "intercept", "coefficients")
682+
.head()
683683
val model = new LogisticRegressionModel(metadata.uid, coefficients, intercept)
684684

685685
DefaultParamsReader.getAndSetParams(model, metadata)

0 commit comments

Comments
 (0)