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_r346961279
 
 

 ##########
 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:
   Hm yeah I don't know if there's a use case for passing parameters to 
elements of a Pipeline this way. It might work, not sure. Anyway I think 
argument from consistency probably still stands.

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