Skip to content

[BUG] Core.get_params() returns fitted attributes and internal state, violating sklearn estimator API #521

@dkstlzk

Description

@dkstlzk

Core.get_params() currently returns self.__dict__ when deep=True.
This exposes fitted attributes and internal state (e.g. coef_, statistics_) in the parameter dictionary.

However, according to the scikit-learn estimator API, get_params() should return only constructor parameters, not attributes created during fit(). Returning fitted attributes can break compatibility with utilities such as sklearn.clone and GridSearchCV.

Minimal Example

from pygam import LinearGAM
import numpy as np

X = np.random.rand(100,1)
y = np.sin(X[:,0])

gam = LinearGAM().fit(X,y)
params = gam.get_params(deep=True)

print("coef_" in params)        # True
print("statistics_" in params)  # True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions