Skip to content

Commit

Permalink
[SPARK-10470] [ML] ml.IsotonicRegressionModel.copy should set parent
Browse files Browse the repository at this point in the history
Copied model must have the same parent, but ml.IsotonicRegressionModel.copy did not set parent.
Here fix it and add test case.

Author: Yanbo Liang <ybliang8@gmail.com>

Closes apache#8637 from yanboliang/spark-10470.
  • Loading branch information
yanboliang authored and mengxr committed Sep 8, 2015
1 parent 5fd5795 commit f7b55db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class IsotonicRegressionModel private[ml] (
def predictions: Vector = Vectors.dense(oldModel.predictions)

override def copy(extra: ParamMap): IsotonicRegressionModel = {
copyValues(new IsotonicRegressionModel(uid, oldModel), extra)
copyValues(new IsotonicRegressionModel(uid, oldModel), extra).setParent(parent)
}

override def transform(dataset: DataFrame): DataFrame = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.apache.spark.ml.regression

import org.apache.spark.SparkFunSuite
import org.apache.spark.ml.param.ParamsSuite
import org.apache.spark.ml.util.MLTestingUtils
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.mllib.util.MLlibTestSparkContext
import org.apache.spark.sql.{DataFrame, Row}
Expand Down Expand Up @@ -89,6 +90,10 @@ class IsotonicRegressionSuite extends SparkFunSuite with MLlibTestSparkContext {
assert(ir.getFeatureIndex === 0)

val model = ir.fit(dataset)

// copied model must have the same parent.
MLTestingUtils.checkCopy(model)

model.transform(dataset)
.select("label", "features", "prediction", "weight")
.collect()
Expand Down

0 comments on commit f7b55db

Please sign in to comment.