huaxingao commented on a change in pull request #29445:
URL: https://github.com/apache/spark/pull/29445#discussion_r474271097
##########
File path: python/pyspark/ml/tests/test_tuning.py
##########
@@ -89,15 +89,50 @@ def test_copy(self):
grid = (ParamGridBuilder()
.addGrid(iee.inducedError, [100.0, 0.0, 10000.0])
.build())
- cv = CrossValidator(estimator=iee, estimatorParamMaps=grid,
evaluator=evaluator)
+ cv = CrossValidator(
+ estimator=iee,
+ estimatorParamMaps=grid,
+ evaluator=evaluator,
+ collectSubModels=True,
+ numFolds=2
+ )
cvCopied = cv.copy()
- self.assertEqual(cv.getEstimator().uid, cvCopied.getEstimator().uid)
+ for param in [
+ lambda x: x.getEstimator().uid,
+ # SPARK-32092: CrossValidator.copy() needs to copy all existing
params
+ lambda x: x.getNumFolds(),
+ lambda x: x.getFoldCol(),
+ lambda x: x.getCollectSubModels(),
+ lambda x: x.getParallelism(),
+ lambda x: x.getSeed()
+ ]:
+ self.assertEqual(param(cv), param(cvCopied))
cvModel = cv.fit(dataset)
cvModelCopied = cvModel.copy()
for index in range(len(cvModel.avgMetrics)):
self.assertTrue(abs(cvModel.avgMetrics[index] -
cvModelCopied.avgMetrics[index])
< 0.0001)
+ # SPARK-32092: CrossValidator.copy() needs to copy all existing params
Review comment:
super nit: do you mean `CrossValidatorModel.copy()`?
----------------------------------------------------------------
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]