hfs.HierarchicalEstimator¶
- class hfs.HierarchicalEstimator(hierarchy: Optional[ndarray] = None)[source]¶
Base class for estimators using hierarchical data.
The HierarchicalEstimator implements scikit-learn’s BaseEstimator and TransformerMixin interfaces. It can be used as a base class for feature selection classes or data preprocessors that use hierarchical data.
- __init__(hierarchy: Optional[ndarray] = None)[source]¶
Initializes a HierarchicalEstimator.
- Parameters
- hierarchynp.ndarray
The hierarchy graph as an adjacency matrix.
- fit(X, y=None, columns=None)[source]¶
Fitting function that prepares the hierarchy and _columns parameter.
The hierarchy is transformed to a nx.DiGraph with a virtual root node named “ROOT” that connects all parts of the graph to one component.
- Parameters
- X{array-like, sparse matrix}, shape (n_samples, n_features)
The training input samples.
- yarray-like, shape (n_samples,) or None
The target values. Only necessary for some estimators.
- columns: list or None
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.