Skip to content

Documentation for FRegressionSelectPercentile

Feature Selection for regression data - percentile based.

Apply VarianceThreshold -> SelectPercentile to data. SelectPercentile based on f_regression and parameter percentile.

Source code in photonai/modelwrapper/feature_selection.py
class FRegressionSelectPercentile(BaseEstimator, TransformerMixin):
    """Feature Selection for regression data - percentile based.

    Apply VarianceThreshold -> SelectPercentile to data.
    SelectPercentile based on f_regression and parameter percentile.

    """
    _estimator_type = "transformer"

    def __init__(self, percentile: float = 10):
        """
        Initialize the object.

        Parameters:
            percentile:
                Percent of features to keep.

        """
        self.var_thres = VarianceThreshold()
        self.percentile = percentile
        self.my_fs = None

    def fit(self, X, y):
        X = self.var_thres.fit_transform(X)
        self.my_fs = SelectPercentile(score_func=f_regression, percentile=self.percentile)
        self.my_fs.fit(X,y)
        return self

    def transform(self, X):
        X = self.var_thres.transform(X)
        return self.my_fs.transform(X)

    def inverse_transform(self, X):
        Xt = self.my_fs.inverse_transform(X)
        return self.var_thres.inverse_transform(Xt)

__init__(self, percentile=10) special

Initialize the object.

Parameters:

Name Type Description Default
percentile float

Percent of features to keep.

10
Source code in photonai/modelwrapper/feature_selection.py
def __init__(self, percentile: float = 10):
    """
    Initialize the object.

    Parameters:
        percentile:
            Percent of features to keep.

    """
    self.var_thres = VarianceThreshold()
    self.percentile = percentile
    self.my_fs = None