You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Numpy data types can be constructed in different ways. Although they result in the same data type, isinstance() yields different results based on the way the data type has been constructed.
Therefore, if an object accepts numpy data types as a parameter, the parameter constraints need to be [type, np.dtype]. Currently this isn't supported, because sklearn.utils._param_validation._InstancesOf initalizes with the built-in type
def __init__(self, type):
self.type = type
This results in errors when trying to implement parameter_constraints in objects with numpy data types as parameters. E.g. #23579
I therefore propose to change the parameter self.type to self.param_type and initialize it with the actual type given within the list of parameter constraints.
Describe the bug
Numpy data types can be constructed in different ways. Although they result in the same data type, isinstance() yields different results based on the way the data type has been constructed.
Therefore, if an object accepts numpy data types as a parameter, the parameter constraints need to be
[type, np.dtype]
. Currently this isn't supported, becausesklearn.utils._param_validation._InstancesOf
initalizes with the built-intype
This results in errors when trying to implement parameter_constraints in objects with numpy data types as parameters. E.g. #23579
I therefore propose to change the parameter self.type to self.param_type and initialize it with the actual type given within the list of parameter constraints.
Steps/Code to Reproduce
See #23579
Expected Results
No error is thrown.
Actual Results
ValueError: The 'dtype' parameter of OneHotEncoder must be an instance of 'type'. Got dtype('float64') instead.
Versions
The text was updated successfully, but these errors were encountered: