Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Maintenance code, support for sci kit-learn version 1.2.2. #40

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ to run stability selection with complementary pairs bootstrapping.

## Feedback and contributing

Feedback and contributions are much appreciated. If you have any feedback, please post it on the [issue tracker](https://github.com/scikit-learn-contrib/stability-selection/issues).
* Feedback and contributions are much appreciated. If you have any feedback, please post it on the [issue tracker](https://github.com/scikit-learn-contrib/stability-selection/issues).


## References

Expand All @@ -115,3 +116,4 @@ Feedback and contributions are much appreciated. If you have any feedback, pleas
error control: another look at stability selection. Journal
of the Royal Statistical Society: Series B (Statistical Methodology),
75(1), pp.55-80.
[3] https://github.com/scikit-learn-contrib/stability-selection
6 changes: 3 additions & 3 deletions examples/plot_randomized_lasso_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def generate_experiment_data(n=200, p=200, rho=0.6, random_state=3245):
lambda_grid = np.linspace(0.001, 0.5, num=100)

for weakness in [0.2, 0.5, 1.0]:
estimator = RandomizedLasso(weakness=weakness)
selector = StabilitySelection(base_estimator=estimator, lambda_name='alpha',
lambda_grid=lambda_grid, threshold=0.9, verbose=1)
estimator = RandomizedLasso(weakness=weakness,normalize=True)
selector = StabilitySelection(base_estimator=estimator, lambda_name='alpha',lambda_grid=lambda_grid,
threshold=0.9, verbose=1)
selector.fit(X, y)

fig, ax = plot_stability_path(selector)
Expand Down
5 changes: 2 additions & 3 deletions examples/plot_stability_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ def _generate_dummy_classification_data(p=1000, n=1000, k=5, random_state=123321

base_estimator = Pipeline([
('scaler', StandardScaler()),
('model', LogisticRegression(penalty='l1'))
('model', LogisticRegression())
])
selector = StabilitySelection(base_estimator=base_estimator, lambda_name='model__C',
lambda_grid=np.logspace(-5, -1, 50))
selector = StabilitySelection(base_estimator=base_estimator, lambda_name='model__C',lambda_grid=np.logspace(-5, -1, 50))
selector.fit(X, y)

fig, ax = plot_stability_path(selector)
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nose>=1.1.2
scikit-learn>=0.19
matplotlib>=2.0.0
numpy>=1.8.0
nose==1.3.7
scikit-learn>=1.2.2
matplotlib==3.7.1
numpy==1.24.3
13 changes: 7 additions & 6 deletions stability_selection/randomized_lasso.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from scipy.sparse import issparse

from sklearn.linear_model import LogisticRegression, Lasso
from sklearn.linear_model.base import _preprocess_data
from sklearn.linear_model._base import _preprocess_data
from sklearn.utils import check_X_y, check_random_state

__all__ = ['RandomizedLogisticRegression', 'RandomizedLasso']
Expand Down Expand Up @@ -120,9 +120,9 @@ def __init__(self, weakness=0.5, alpha=1.0, fit_intercept=True, normalize=False,
tol=1e-4, warm_start=False, positive=False,
random_state=None, selection='cyclic'):
self.weakness = weakness
self.normalize = normalize
super(RandomizedLasso, self).__init__(
alpha=alpha, fit_intercept=fit_intercept,
normalize=normalize, precompute=precompute, copy_X=copy_X,
alpha=alpha, fit_intercept=fit_intercept, precompute=precompute, copy_X=copy_X,
max_iter=max_iter, tol=tol, warm_start=warm_start,
positive=positive, random_state=random_state,
selection=selection)
Expand All @@ -149,9 +149,10 @@ def fit(self, X, y):

weights = weakness * random_state.randint(0, 1 + 1, size=(n_features,))

# TODO: I am afraid this will do double normalization if set to true
#X, y, _, _ = _preprocess_data(X, y, self.fit_intercept, normalize=self.normalize, copy=False,
# sample_weight=None, return_mean=False)
# TODO: I am afraid this will do double normalization if set to true.
X, y, X_offset, y_offset, X_scale = _preprocess_data(X, y, self.fit_intercept,
normalize=self.normalize,copy=False,
sample_weight=None,check_input=True)

# TODO: Check if this is a problem if it happens before standardization
X_rescaled = _rescale_data(X, weights)
Expand Down
5 changes: 3 additions & 2 deletions stability_selection/stability_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
"""

from warnings import warn

import matplotlib.pyplot as plt
import numpy as np
from sklearn.base import BaseEstimator, TransformerMixin, clone
from sklearn.externals.joblib import Parallel, delayed
from joblib import Parallel, delayed


from sklearn.feature_selection import SelectFromModel
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline
Expand Down