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

We might need to restrict sklearn dependency to earlier versions #134

Open
arokem opened this issue Jan 25, 2023 · 0 comments
Open

We might need to restrict sklearn dependency to earlier versions #134

arokem opened this issue Jan 25, 2023 · 0 comments

Comments

@arokem
Copy link
Collaborator

arokem commented Jan 25, 2023

With current version setting (i.e., latest sklearn), the following code:

pca = GroupPCA(groups=group_indices, n_components=0.95)
gpca = gpca.fit(X_train)
groups_pca = gpca.groups_out_

X_train = gpca.transform(X_train)

model = make_afq_regressor_pipeline(
    imputer_kwargs={"strategy": "median"},
    use_cv_estimator=True,
    scaler="standard",
    groups=groups_pca,
    verbose=0,
    pipeline_verbosity=False,
    tuning_strategy="bayes",
    cv=3,
    n_bayes_points=9,
    n_jobs=28,
    l1_ratio=[0.0, 1.0],
    eps=5e-2,
    n_alphas=100,
)

model.fit(X_train, y_train)

Raises:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[40], line 1
----> 1 model.fit(X_train, y_train)

File ~/miniconda3/envs/age_trt/lib/python3.10/site-packages/sklearn/pipeline.py:405, in Pipeline.fit(self, X, y, **fit_params)
    403     if self._final_estimator != "passthrough":
    404         fit_params_last_step = fit_params_steps[self.steps[-1][0]]
--> 405         self._final_estimator.fit(Xt, y, **fit_params_last_step)
    407 return self

File ~/miniconda3/envs/age_trt/lib/python3.10/site-packages/groupyr/sgl.py:1024, in SGLCV.fit(self, X, y)
   1022 n_l1_ratio = len(l1_ratios)
   1023 if alphas is None:
-> 1024     alphas = [
   1025         _alpha_grid(
   1026             X=X,
   1027             y=y,
   1028             groups=groups,
   1029             scale_l2_by=self.scale_l2_by,
   1030             l1_ratio=l1_ratio,
   1031             fit_intercept=self.fit_intercept,
   1032             eps=self.eps,
   1033             n_alphas=self.n_alphas,
   1034             normalize=self.normalize,
   1035             copy_X=self.copy_X,
   1036         )
   1037         for l1_ratio in l1_ratios
   1038     ]
   1039 else:
   1040     # Making sure alphas is properly ordered.
   1041     alphas = np.tile(np.sort(alphas)[::-1], (n_l1_ratio, 1))

File ~/miniconda3/envs/age_trt/lib/python3.10/site-packages/groupyr/sgl.py:1025, in <listcomp>(.0)
   1022 n_l1_ratio = len(l1_ratios)
   1023 if alphas is None:
   1024     alphas = [
-> 1025         _alpha_grid(
   1026             X=X,
   1027             y=y,
   1028             groups=groups,
   1029             scale_l2_by=self.scale_l2_by,
   1030             l1_ratio=l1_ratio,
   1031             fit_intercept=self.fit_intercept,
   1032             eps=self.eps,
   1033             n_alphas=self.n_alphas,
   1034             normalize=self.normalize,
   1035             copy_X=self.copy_X,
   1036         )
   1037         for l1_ratio in l1_ratios
   1038     ]
   1039 else:
   1040     # Making sure alphas is properly ordered.
   1041     alphas = np.tile(np.sort(alphas)[::-1], (n_l1_ratio, 1))

File ~/miniconda3/envs/age_trt/lib/python3.10/site-packages/groupyr/sgl.py:233, in _alpha_grid(X, y, Xy, groups, scale_l2_by, l1_ratio, fit_intercept, eps, n_alphas, normalize, copy_X, model)
    166 """Compute the grid of alpha values for elastic net parameter search.
    167 
    168 Parameters
   (...)
    230     for classification.
    231 """
    232 if l1_ratio == 1.0:
--> 233     return _lasso_alpha_grid(
    234         X=X,
    235         y=y,
    236         Xy=Xy,
    237         l1_ratio=l1_ratio,
    238         fit_intercept=fit_intercept,
    239         eps=eps,
    240         n_alphas=n_alphas,
    241         normalize=normalize,
    242         copy_X=copy_X,
    243     )
    245 n_samples = len(y)
    246 if Xy is None:

TypeError: _alpha_grid() got an unexpected keyword argument 'normalize'

But if I roll back to sklearn==1.0 I no longer get that error.

Might be related to scikit-learn/scikit-learn#24391

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