Skip to content

SparseCoder does not follow the scikit-learn API and will break in 0.24 #16336

@glemaitre

Description

@glemaitre

The SparseCoder does not follow the scikit-learn API.

d = np.array([[1, 2, 3], [1, 2, 3]])
sc = SparseCoder(dictionary=d)
sc.get_params()
/home/glemaitre/Documents/packages/scikit-learn/sklearn/base.py:204:
FutureWarning: From version 0.24, get_params will raise an AttributeError 
if a parameter cannot be retrieved as an instance attribute. 
Previously it would return None. FutureWarning)

The reason is that we initialize self.components_ = dictionary meaning that self.dictionary does not exist which raises the warning and will error in 0.24.
Basically, set_params will not work as well then.

So we should probably solve this issue.

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