srowen commented on a change in pull request #26527: [SPARK-29691][ML][PYTHON] 
ensure Param objects are valid in fit, transform
URL: https://github.com/apache/spark/pull/26527#discussion_r346706592
 
 

 ##########
 File path: python/pyspark/ml/param/__init__.py
 ##########
 @@ -484,8 +484,19 @@ def _copyValues(self, to, extra=None):
         :return: the target instance with param values copied
         """
         paramMap = self._paramMap.copy()
-        if extra is not None:
-            paramMap.update(extra)
+        if isinstance(extra, dict):
+            for param, value in extra.items():
+                if isinstance(param, Param):
+                    paramMap[param] = value
+                elif self.hasParam(param):
+                    # set value by name if vaiid
+                    paramMap[self.getParam(param)] = value
 
 Review comment:
   I don't know if we should support this, as it isn't specified this way (by 
name) elsewhere. Part of the reason is that it can be ambiguous if you have 
multiple instances of the same transformer in the pipeline? I'm only surprised 
it wouldn't already fail, so indeed maybe the validation below is reasonable.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to