Louiszr commented on a change in pull request #29445:
URL: https://github.com/apache/spark/pull/29445#discussion_r474527105
##########
File path: python/pyspark/ml/tuning.py
##########
@@ -536,7 +536,7 @@ def copy(self, extra=None):
bestModel = self.bestModel.copy(extra)
avgMetrics = self.avgMetrics
subModels = self.subModels
- return CrossValidatorModel(bestModel, avgMetrics, subModels)
+ return self._copyValues(CrossValidatorModel(bestModel, avgMetrics,
subModels), extra=extra)
Review comment:
By shallow copy I mean `copy.copy()` in python, which makes re-assigning
`cvModel.avgMetrics[0]` not being propagated to `cvModelCopied.avgMetrics[0]`.
I am also using `copy.deepcopy()` as the reference for deep copy. If
`cvModel.avgMetrics[0]` is an class instance, then shallow copy will point to
the same instance, while deep copy will create a copy of the instance.
I think here it doesn't make a difference because `avgMetrics` is a list of
`float`, but in the future if it does become a list of objects then a shallow
copy implementation will be sufficient to pass the test.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]