Home > OS >  How to find the sklearn version?
How to find the sklearn version?

Time:01-27

I have a pickled sklearn model, which I need to get to run. This model, however, is trained in unknown version of sklearn.

When I look up the model in debugger, I find that there is a bunch of strange tracebacks inside, instead of the keys you'd expect, for example:

decision_function -> 'RandomForestClassifier' object has no attribute 'decision_function'
fit_predict -> 'RandomForestClassifier' object has no attribute 'fit_predict'
score_samples -> 'RandomForestClassifier' object has no attribute 'score_samples'

How can I get this model to run? Does these error message hint you anything?

CodePudding user response:

You can know the version of a pickled model after scikit-learn 0.18. Using

model.__getstate__()['_sklearn_version']

So at least you will know if it is pre 0.18 or newer.

  • Related