PivotTreeStump#
- class PivotTreeStump[source]#
Bases:
objectMixin of the pivot stumps (PivotTreeStumpClassifier and PivotTreeStumpRegressor): the PivotTransformer built from the parameters of the stump, the pivots of the split and its rule.
The subclass defines the parameters and the splitter, by deriving also from the decision tree stump of its task (
class PivotTreeStumpClassifier(PivotTreeStump, DecisionTreeStumpClassifier)).- property X_split_instance#
The pivot of the split, standardized (categorical features one-hot encoded); None if not fitted.
- get_pivots()[source]#
Pivots of the node, as indices of instances of the training set.
- Returns:
pivots –
descriptives(medoids),discriminativesandcandidates(both) pivots of the node, and the pivotusedby the split.- Return type:
Examples
>>> from sklearn.datasets import load_iris >>> from RuleTree.stumps.classification import PivotTreeStumpClassifier >>> X, y = load_iris(return_X_y=True) >>> pivots = PivotTreeStumpClassifier(random_state=0) >>> pivots = pivots.fit(X, y, context=None, node_id=None, cache=None).get_pivots() >>> pivots["descriptives"], pivots["discriminatives"], pivots["used"] ([7, 99, 147], [27, 76, 108], 76)
- get_rule(columns_names=None, scaler=None, float_precision=3)[source]#
Rule of the split,
P_<i> <= threshold, whereP_<i>is the distance from the training instancei.- Parameters:
columns_names (list of str, default=None) – Not used: the rule does not name the features.
scaler (TransformerMixin, default=None) – Not used: the distances are computed on the data standardized by the stump.
float_precision (int, default=3) – Number of decimals of the threshold; None for no rounding.
- Returns:
rule –
feature_idx(the pivot),threshold,is_categorical,feature_name, the condition of the left child (textual_rule,blob_rule) and its negation (not_textual_rule,not_blob_rule). Empty if the stump is not fitted.- Return type: