Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT - Make GeneralizedLinearEstimator compatible with GridSearchCV #255

Open
mathurinm opened this issue May 31, 2024 · 0 comments
Open

Comments

@mathurinm
Copy link
Collaborator

mathurinm commented May 31, 2024

Because the parameters that we would like to cross validate are parameters of model.penalty, model.datafit or model.solver, we are not comaptible:

from skglm.utils.data import make_correlated_data
from skglm.datafits import Quadratic
from skglm.penalties import L1
from skglm import GeneralizedLinearEstimator

from sklearn.model_selection import GridSearchCV
import numpy as np

X, y,_ = make_correlated_data()

model = GeneralizedLinearEstimator(Quadratic(), L1(alpha=1))
alpha_grid = np.geomspace(1, 1e-2)

cv = GridSearchCV(model, param_grid={"alpha": alpha_grid}, scoring="neg_mean_squared_error").fit(X, y)

gives
TypeError: GeneralizedLinearEstimator.__init__() got an unexpected keyword argument 'penalty__alpha'

How could we solve this? Maybe @glemaitre or @agramfort have an idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant