hfs.EagerHierarchicalFeatureSelector

class hfs.EagerHierarchicalFeatureSelector(hierarchy: Optional[ndarray] = None)[source]

Base class for eager feature selectors using hierarchical data.

__init__(hierarchy: Optional[ndarray] = None)[source]

Initializes an EagerHierarchicalFeatureSelector.

Parameters
hierarchynp.ndarray

The hierarchy graph as an adjacency matrix.

fit(X, y=None, columns=None)[source]

Fitting function that sets representatives.

After fitting representatives should include the names of all nodes from the hierarchy that are left after feature selection. The number of columns in X and the number of nodes in the hierarchy are expected to be the same and each column should be mapped to exactly one node in the hierarchy with the columns parameter.

Parameters
X{array-like, sparse matrix}, shape (n_samples, n_features)

The training input samples.

yarray-like, shape (n_samples,)

The target values. An array of int. Not needed for all estimators.

columns: list or None, length n_features

The mapping from the hierarchy graph’s nodes to the columns in X. A list of ints. If this parameter is None the columns in X and the corresponding nodes in the hierarchy are expected to be in the same order.

Returns
selfobject

Returns self.

transform(X)[source]

Reduce X to the selected features.

Extends the transform method from SelectorMixin. Only selected columns from X are in the output dataset.

Parameters
Xarray of shape (n_samples, n_features)

The input samples.

Returns
Xarray of shape [n_samples, n_selected_features]

The input samples with only the selected features.