This repository was archived by the owner on Feb 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
We might need to restrict sklearn dependency to earlier versions #134
Copy link
Copy link
Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels