Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-10479] [SPARK-10480] [ML] Fix ML.LinearRegressionModel.copy() #8641

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,9 @@ class LogisticRegressionModel private[ml] (
}

override def copy(extra: ParamMap): LogisticRegressionModel = {
copyValues(new LogisticRegressionModel(uid, weights, intercept), extra).setParent(parent)
val newModel = copyValues(new LogisticRegressionModel(uid, weights, intercept), extra)
if (trainingSummary.isDefined) newModel.setSummary(trainingSummary.get)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking, was this intended as well? does it need to happen for LinearRegression too? LGTM otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's needed. Because after we new LogisticRegressionModel or LinearRegressionModel, the default value of trainingSummary is None. So we should also copy trainingSummary explicitly to the new model.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. newModel.trainingSummary = trainingSummary should work the same.

newModel.setParent(parent)
}

override protected def raw2prediction(rawPrediction: Vector): Double = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class LinearRegressionModel private[ml] (
}

override def copy(extra: ParamMap): LinearRegressionModel = {
val newModel = copyValues(new LinearRegressionModel(uid, weights, intercept))
val newModel = copyValues(new LinearRegressionModel(uid, weights, intercept), extra)
if (trainingSummary.isDefined) newModel.setSummary(trainingSummary.get)
newModel.setParent(parent)
}
Expand Down