How to find the sklearn version?

Question:

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?

EDIT: The solution is to brute force search the sklearn version. In my case when I got to the correct major version, the error message pointed me to the correct minor version.

Asked By: Artur Pschybysz

||

Answers:

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.

Answered By: Santiago Isaza
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.