Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/19892#discussion_r157416631
--- Diff: python/pyspark/ml/param/__init__.py ---
@@ -134,6 +134,20 @@ def toListFloat(value):
return [float(v) for v in value]
raise TypeError("Could not convert %s to list of floats" % value)
+ @staticmethod
+ def toListListFloat(value):
+ """
+ Convert a value to list of list of floats, if possible.
+ """
+ if TypeConverters._can_convert_to_list(value):
+ value = TypeConverters.toList(value)
+ if all(map(lambda v: TypeConverters._can_convert_to_list(v),
value)):
+ ll = []
+ for v in value:
+ ll.append([float(i) for i in TypeConverters.toList(v)])
--- End diff --
`toListFloat` requires each list entry is a numeric
`TypeConverters._is_numeric`. Should `toListListFloat` have such requirement?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]