skrobot.feature_selection package

Submodules

skrobot.feature_selection.column_selector module

class skrobot.feature_selection.column_selector.ColumnSelector(cols, drop_axis=False)[source]

Bases: sklearn.base.BaseEstimator

The ColumnSelector class is an implementation of a column selector for scikit-learn pipelines.

It can be used for manual feature selection to select specific columns from an input data set.

It can select columns either by integer indices or by names.

__init__(cols, drop_axis=False)[source]

This is the constructor method and can be used to create a new object instance of ColumnSelector class.

Parameters
  • cols (list) – A non-empty list specifying the columns to be selected. For example, [1, 4, 5] to select the 2nd, 5th, and 6th columns, and [‘A’,’C’,’D’] to select the columns A, C and D.

  • drop_axis (bool, optional) – Can be used to reshape the output data set from (n_samples, 1) to (n_samples) by dropping the last axis. It defaults to False.

fit_transform(X, y=None)[source]

Returns a slice of the input data set.

Parameters
  • X ({NumPy array, pandas DataFrame, SciPy sparse matrix}) – Input vectors of shape (n_samples, n_features), where n_samples is the number of samples and n_features is the number of features.

  • y (None) – Ignored.

Returns

Subset of the input data set of shape (n_samples, k_features), where n_samples is the number of samples and k_features <= n_features.

Return type

{NumPy array, SciPy sparse matrix}

transform(X, y=None)[source]

Returns a slice of the input data set.

Parameters
  • X ({NumPy array, pandas DataFrame, SciPy sparse matrix}) – Input vectors of shape (n_samples, n_features), where n_samples is the number of samples and n_features is the number of features.

  • y (None) – Ignored.

Returns

Subset of the input data set of shape (n_samples, k_features), where n_samples is the number of samples and k_features <= n_features.

Return type

{NumPy array, SciPy sparse matrix}

fit(X, y=None)[source]

This is a mock method and does nothing.

Parameters
  • X (None) – Ignored.

  • y (None) – Ignored.

Returns

The object instance itself.

Return type

ColumnSelector