(self, X, y)
return self
Fit the stability selection model on the given data.

        Parameters
        ----------
        X : {array-like, sparse matrix}, shape = [n_samples, n_features]
            The training input samples.

        y : array-like, shape = [n_samples]
            The target values.
Fit the stability selection model on the given data.
Fit the stability selection model on the given data .
def fit(self, X, y):
        """Fit the stability selection model on the given data.

        Parameters
        ----------
        X : {array-like, sparse matrix}, shape = [n_samples, n_features]
            The training input samples.

        y : array-like, shape = [n_samples]
            The target values.
        """

        self._validate_input()

        X, y = check_X_y(X, y, accept_sparse='csr')

        n_samples, n_variables = X.shape
        n_subsamples = np.floor(self.sample_fraction * n_samples).astype(int)
        n_lambdas = self.lambda_grid.shape[0]

        base_estimator = clone(self.base_estimator)
        random_state = check_random_state(self.random_state)
        stability_scores = np.zeros((n_variables, n_lambdas))

        for idx, lambda_value in enumerate(self.lambda_grid):
            if self.verbose > 0:
                print("Fitting estimator for lambda = %.5f (%d / %d) on %d bootstrap samples" %
                      (lambda_value, idx + 1, n_lambdas, self.n_bootstrap_iterations))

            bootstrap_samples = _bootstrap_generator(self.n_bootstrap_iterations,
                                                     self.bootstrap_func, y,
                                                     n_subsamples, random_state=random_state)

            selected_variables = Parallel(
                n_jobs=self.n_jobs, verbose=self.verbose,
                pre_dispatch=self.pre_dispatch
            )(delayed(_fit_bootstrap_sample)(clone(base_estimator),
                                             X=X[safe_mask(X, subsample), :],
                                             y=y[subsample],
                                             lambda_name=self.lambda_name,
                                             lambda_value=lambda_value,
                                             threshold=self.bootstrap_threshold)
              for subsample in bootstrap_samples)

            stability_scores[:, idx] = np.vstack(selected_variables).mean(axis=0)

        self.stability_scores_ = stability_scores
        return self
def fit ( self , X , y ) : self . _validate_input ( ) X , y = check_X_y ( X , y , accept_sparse = 'csr' ) n_samples , n_variables = X . shape n_subsamples = np . floor ( self . sample_fraction * n_samples ) . astype ( int ) n_lambdas = self . lambda_grid . shape [ 0 ] base_estimator = clone ( self . base_estimator ) random_state = check_random_state ( self . random_state ) stability_scores = np . zeros ( ( n_variables , n_lambdas ) ) for idx , lambda_value in enumerate ( self . lambda_grid ) : if self . verbose > 0 : print ( "Fitting estimator for lambda = %.5f (%d / %d) on %d bootstrap samples" % ( lambda_value , idx + 1 , n_lambdas , self . n_bootstrap_iterations ) ) bootstrap_samples = _bootstrap_generator ( self . n_bootstrap_iterations , self . bootstrap_func , y , n_subsamples , random_state = random_state ) selected_variables = Parallel ( n_jobs = self . n_jobs , verbose = self . verbose , pre_dispatch = self . pre_dispatch ) ( delayed ( _fit_bootstrap_sample ) ( clone ( base_estimator ) , X = X [ safe_mask ( X , subsample ) , : ] , y = y [ subsample ] , lambda_name = self . lambda_name , lambda_value = lambda_value , threshold = self . bootstrap_threshold ) for subsample in bootstrap_samples ) stability_scores [ : , idx ] = np . vstack ( selected_variables ) . mean ( axis = 0 ) self . stability_scores_ = stability_scores return self