[SPARK-10470] [ML] ml.IsotonicRegressionModel.copy should set parent
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 #8637 from yanboliang/spark-10470.
This commit is contained in:
parent
5fd57955ef
commit
f7b55dbfc3
|
@ -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 = {
|
||||
|
|
|
@ -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}
|
||||
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue