Base Classes and Mixins

FSFC uses some base classes and mixins, based on sklearn estimators and classifiers. It makes the library fully compatible with sklearn, so feature selectors can be used in pipelines

Mixins

Some default mixins which extend ones defined in sklearn

class fsfc.mixins.KBestSelectorMixin[source]

Bases: fsfc.mixins.ScoreSelectorMixin

Mixin that selects K best features according to their scores

class fsfc.mixins.ScoreSelectorMixin[source]

Bases: object

Mixin that adds getter for calculation of scores of features and checks that scores are calculated

class fsfc.mixins.ThresholdSelectorMixin[source]

Bases: fsfc.mixins.ScoreSelectorMixin

Mixin that selects features according to some threshold. That means that all features whose score is higher than threshold are selected

Classes

Base classes of all feature selecting / clustering algorithms of FSFC

class fsfc.base.BaseFeatureSelector[source]

Bases: sklearn.base.BaseEstimator, sklearn.feature_selection.base.SelectorMixin

Base class for all feature selection algorithms. It’s SKLearn-compliant, so it can be used in pipelines.

Successors should override methods fit() and _get_support_mask().

Methods

fit(x, *rest) Fit selector to a dataset.
fit_transform(X[, y]) Fit to data, then transform it.
get_params([deep]) Get parameters for this estimator.
get_support([indices]) Get a mask, or integer index, of the features selected
inverse_transform(X) Reverse the transformation operation
set_params(**params) Set the parameters of this estimator.
transform(X) Reduce X to the selected features.
fit(x, *rest)[source]

Fit selector to a dataset.

Parameters:
x: ndarray

The input samples - array of shape [n_samples, n_features].

rest: list

List of miscellaneous arguments.

Returns:
selector: BaseFeatureSelector

Returns self to support chaining.

class fsfc.base.ClusteringFeatureSelector(k)[source]

Bases: fsfc.mixins.KBestSelectorMixin, fsfc.base.BaseFeatureSelector, sklearn.base.ClusterMixin

Clusters samples and simultaneously finds relevant features. Allows to transform dataset and select K best features according to features scores.

Parameters:
k: int

Number of features to select

Methods

fit(x, *rest)
fit_predict(X[, y]) Performs clustering on X and returns cluster labels.
fit_transform(X[, y]) Fit to data, then transform it.
get_params([deep]) Get parameters for this estimator.
get_support([indices]) Get a mask, or integer index, of the features selected
inverse_transform(X) Reverse the transformation operation
set_params(**params) Set the parameters of this estimator.
transform(X) Reduce X to the selected features.
fit(x, *rest)[source]
class fsfc.base.KBestFeatureSelector(k)[source]

Bases: fsfc.mixins.KBestSelectorMixin, fsfc.base.BaseFeatureSelector

Base class for algorithms that selects K best features according to features scores.

Successors should override method _calc_scores() for computation of the score.

Parameters:
k: int

Number of features to select

Methods

fit(x, *rest)
fit_transform(X[, y]) Fit to data, then transform it.
get_params([deep]) Get parameters for this estimator.
get_support([indices]) Get a mask, or integer index, of the features selected
inverse_transform(X) Reverse the transformation operation
set_params(**params) Set the parameters of this estimator.
transform(X) Reduce X to the selected features.
fit(x, *rest)[source]