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
Edit: This comment is edited heavily multiple times while working on this issue. I finally edited all parts out not related to this issue, and it is now final.
I ran into this as well. In my case I wanted to specify all possible labels for the scikit-learn OrdinalEncoder, and the possible labels were retrieved from the dataset, which was stored as numpy floats. Extending for numpy types should be relatively simple, given we can retrieve them programmatically:
simple_numpy_types = [nptype for type_cat, nptypes in np.sctypes.items()
for nptype in nptypes
if type_cat != 'others']
simple_types = tuple([bool, int, float, str] + simple_numpy_types)
and then elif isinstance(o, simple_types) or o is None:
It appears like this is a common feature request. The only thing I'm a bit worried about is that we cannot easily do the de-serialization and get a numpy dtype again. Maybe that is not an issue for simple scalars but only for arrays?
For the types that would now be included for serialization (various bit-length ints, uints, floats and complex), I don't foresee an issue. Could you come up with a concrete issue where it would matter? Otherwise I think it it's smarter to add this feature and tackle the problem if it actually comes up.
Activity
mfeurer commentedon Sep 2, 2017
Correct, but why can't you use normal integers?
PGijsbers commentedon Mar 3, 2019
Edit: This comment is edited heavily multiple times while working on this issue. I finally edited all parts out not related to this issue, and it is now final.
I ran into this as well. In my case I wanted to specify all possible labels for the scikit-learn OrdinalEncoder, and the possible labels were retrieved from the dataset, which was stored as numpy floats. Extending for numpy types should be relatively simple, given we can retrieve them programmatically:
e.g.
and then
elif isinstance(o, simple_types) or o is None:PGijsbers commentedon Mar 3, 2019
First off, a (artificial) minimal example that exposes the issue:
this currently raises
After patching in the
simple_typescheck of the previous comment, the following error is raised instead:So we could extend the
sklearn_to_flowby casting to the native data types:This seems to work as expected.
mfeurer commentedon Mar 4, 2019
It appears like this is a common feature request. The only thing I'm a bit worried about is that we cannot easily do the de-serialization and get a numpy dtype again. Maybe that is not an issue for simple scalars but only for arrays?
PGijsbers commentedon Mar 4, 2019
For the types that would now be included for serialization (various bit-length ints, uints, floats and complex), I don't foresee an issue. Could you come up with a concrete issue where it would matter? Otherwise I think it it's smarter to add this feature and tackle the problem if it actually comes up.
mfeurer commentedon Mar 4, 2019
Makes sense. Please assign me to your PR once it is ready.
mfeurer commentedon Mar 5, 2019
Closed via #635.