'Fit the RFE model and automatically tune the number of selected
features.
Parameters
X : {array-like, sparse matrix}, shape = [n_samples, n_features]
Training vector, where `n_samples` is the number of samples and
`n_features` is the total number of features.
y : array-like, shape = [n_samples]
Target values (integers for classification, real numbers for
regression).'

def fit(self, X, y):

    (X, y) = check_X_y(X, y, 'csr')
    cv = check_cv(self.cv, y, is_classifier(self.estimator))
    scorer = check_scoring(self.estimator, scoring=self.scoring)
    n_features = X.shape[1]
    n_features_to_select = 1
    if (0.0 < self.step < 1.0):
        step = int(max(1, (self.step * n_features)))
    else:
        step = int(self.step)
    if (step <= 0):
        raise ValueError('Step    must    be    >0')
    rfe = RFE(estimator=self.estimator, n_features_to_select=n_features_to_select, step=self.step, verbose=self.verbose)
    if (self.n_jobs == 1):
        (parallel, func) = (list, _rfe_single_fit)
    else:
        (parallel, func) = (Parallel(n_jobs=self.n_jobs), delayed(_rfe_single_fit))
    scores = parallel((func(rfe, self.estimator, X, y, train, test, scorer) for (train, test) in cv.split(X, y)))
    scores = np.sum(scores, axis=0)
    n_features_to_select = max((n_features - (np.argmax(scores) * step)), n_features_to_select)
    rfe = RFE(estimator=self.estimator, n_features_to_select=n_features_to_select, step=self.step)
    rfe.fit(X, y)
    self.support_ = rfe.support_
    self.n_features_ = rfe.n_features_
    self.ranking_ = rfe.ranking_
    self.estimator_ = clone(self.estimator)
    self.estimator_.fit(self.transform(X), y)
    self.grid_scores_ = (scores[::(-1)] / cv.get_n_splits(X, y))
    return self
