Skip to content

Add an attribute to determine which version of sklearn a model was pickled with #22055

@kennysong

Description

@kennysong

Our team works with pickles from several sklearn versions, so we'd like a way to programmatically determine which version a pickle was saved from.

This information is already saved in the pickle file under the attribute _sklearn_version. However, immediately after unpickling, _sklearn_version gets overwritten with the current scikit-learn library's version.

It would be great if BaseEstimator. __setstate__() stores the original _sklearn_version in another attribute like _sklearn_pickle_version.

(Right now, we have to parse the warning message "Trying to unpickle estimator DecisionTreeClassifier from version 1.0 when using version 0.24.2." to get the original version number.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions