Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with scikit-learn > 0.21.3 #109

Open
igorkurinnyi opened this issue Nov 19, 2021 · 1 comment
Open

Compatibility with scikit-learn > 0.21.3 #109

igorkurinnyi opened this issue Nov 19, 2021 · 1 comment

Comments

@igorkurinnyi
Copy link

Hello,

Currently, dragnet is not compatible with scikit-learn > 0.21.3. I did research and composed a table of compatibilities of pickled dragnet models with new sklearn versions.

Trained with version Compatible with versions Not compatible from version Error
1.0.1 1.0.1; 0.24.2 0.23.2 AttributeError: 'ExtraTreeClassifier' object has no attribute 'n_features_'
0.23.2 0.23.2; 0.22.1 0.21.3 ModuleNotFoundError: No module named 'sklearn.ensemble._forest'

Models were trained with: python 3.9, Cython==0.29.24, numpy==1.21.4, scipy==1.7.2

Is it possible to update the library with new models? I could help with a pull request.

@ericluugg
Copy link

Not sure its possible to train the models on newer versions, but for loading pretrained models on higher scikit-learn versions you can redirect imports so they're not looking for nonexistent paths
From there repickle the model so you don't have to redirect the import everytime you want to load the model

import joblib
from sklearn.ensemble import _forest
from sklearn.tree import _classes
sys.modules['sklearn.tree.tree'] = _classes
sys.modules['sklearn.ensemble.forest'] = _forest
def dump_310():
    # Dump the model with new references
    model = joblib.load("/old_model.pkl.gz")
    joblib.dump(model, "updated_model.pkl.gz", compress=3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants