modAL-python / modAL

A modular active learning framework for Python
https://modAL-python.github.io/
MIT License
2.22k stars 324 forks source link

_add_training_data and _fit_on_new does not work with custom data types #49

Open jangedoo opened 5 years ago

jangedoo commented 5 years ago

I have a sklearn pipeline that accepts custom data type as input but it when I use that pipeline and teach the learner, I get the following error TypeError: float() argument must be a string or a number, not 'MyClass'

I traced the problem back to check_X_y function used in BaseLearner. I added dtype=None so that it preserves the input type instead of trying to convert it to a numeric and it didn't throw any errors and works as expected.

I think that behaviour should be expected instead of it trying to convert our data types for us.

cosmic-cortex commented 5 years ago

Thanks, you are completely right! I have added dtype=None arguments for all check_X_y calls, will add a test soon to ensure that working with custom data types won't break in the future.