modAL-python / modAL

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

1-D arrays for learner.teach() #15

Closed nikolay-bushkov closed 6 years ago

nikolay-bushkov commented 6 years ago

Hello! I am trying to use modAL with a sklearn pipeline described here. So, the X_training shape is (n_samples,) rather than (n_samples, n_features). Learner creation works well but after successful querying I could not pass query_inst to the learner.teach(), because it internally calls np.vstack((X_seed, query_inst)). Why not use here np.concatenate(X_seed, query_inst) in the same way as it is used for labels?

Also, I expect that only_new=True will solve this, but no...

cosmic-cortex commented 6 years ago

Hi! I'll look into this and fix the problem soon!

cosmic-cortex commented 6 years ago

I have fixed the issue, the numpy.vstack calls are replaced with numpy.concatenate. In principle, this should work for you. It is merged to the dev, you can install directly from github with pip install git+https://github.com/cosmic-cortex/modAL.git@dev! In any case, let me know here so I can fix the remaining problems or close the issue!

nikolay-bushkov commented 6 years ago

I made a workaround... just X.reshape(-1, 1) and then add FunctionTransformer(lambda X: X.reshape(-1)) to sklearn pipeline. It works, but your fix will definitely help in the future. Thanks!

cosmic-cortex commented 6 years ago

Ok, thanks! In the very near future, I will thoroughly test modAL using PyTorch models with skorch, please let me know if there are any issues! I would like PyTorch/skorch workflows to be fully usable in modAL without any problems.