ObliqueProximityPivotTreeStumpClassifier#
- class ObliqueProximityPivotTreeStumpClassifier(distance_measure='euclidean', oblique_split_type='householder', max_oblique_features=2, tau=0.0001, n_orientations=10, criterion='gini', min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=None, random_state=None, min_impurity_decrease=0.0, class_weight=None, standardize=True, embedder=None)[source]#
Bases:
ProximityPivotTreeStump,DecisionTreeStumpClassifierOblique proximity pivot stump for classification of tabular data, time series and images: as :class: ~RuleTree.stumps.classification.ProximityPivotTreeStumpClassifier.ProximityPivotTreeStumpClassifier ` (the instances closer to one pivot than to another one go left, ``P_a <= P_b`), but the discriminative pivots of each class are the instances combined by an oblique direction on the distances (
oblique_split_type), instead of the root split of a decision tree: up tomax_oblique_features(Householder) or two (bivariate) for each class.It is a
Stumpmade of a ProximityPivotTransformer and a ClassificationSplitter.- Parameters:
distance_measure (str or callable, default='euclidean') – Distance between the instances, computed on the standardized features (categorical ones one-hot encoded): any metric of
sklearn.metrics.pairwise_distances.standardize (bool, default=True) – Whether the features (or the embeddings) are standardized (z-score) before the distances, so that each of them weighs the same.
embedder (transformer, default=None) – Transformer of the data into vectors, e.g.
RuleTree.utils.embeddings.ImageEmbedderorTextEmbedder(with it, also texts are supported): the distances (distance_measure) are computed on the standardized embeddings. Pretrained or stateless (see PivotTransformer). If None, time series and images are flattened.oblique_split_type ({'householder', 'bivariate'}, default='householder') – How the oblique directions that find the discriminative pivots are chosen (see ObliqueDecisionTreeStumpClassifier).
max_oblique_features (int, default=2) – Householder only: maximum number of pivots combined by a direction.
tau (float, default=1e-4) – Householder only: if the principal component is closer than tau to every axis, the directions are the axes.
n_orientations (int, default=10) – Bivariate only: number of angles, evenly spaced in [0, 180) degrees.
criterion ({'gini', 'entropy'}, default='gini') – Impurity measure.
min_samples_leaf (int or float, default=1) – Minimum number of instances in each child (a fraction of the instances of the node if float). Applies to the numerical features.
min_weight_fraction_leaf (float, default=0.0) – Minimum fraction of the sample weights of the node in each child. Applies to the numerical features.
max_features (int, float, {'sqrt', 'log2'} or None, default=None) – Number of numerical features considered for the split, drawn at random; None for all.
random_state (int, RandomState instance or None, default=None) – Seed of the choice of the features (
max_features) and of the ties between features with the same gain. With None, a tree gives the stump its ownrandom_state.min_impurity_decrease (float, default=0.0) – A numerical split is kept only if it decreases the weighted impurity by at least this value.
class_weight (dict, 'balanced' or None, default=None) – Weights of the classes in the impurity; ‘balanced’ weighs them inversely to their frequency.
- Variables:
transformer (ProximityPivotTransformer) – The fitted transformer.
splitter (ClassificationSplitter) – The fitted splitter (feature, threshold, gain and impurity of the split).
data_type (str) – Data type the stump was fitted on.
feature_original (tuple of int) – Indices (in the training set) of the two pivots of the split.
See also
ProximityPivotTreeStumpClassifierthe discriminative pivots found by a decision tree.
ObliquePivotTreeStumpClassifieran oblique split on the distances from the pivots.
Examples
>>> from sklearn.datasets import load_iris >>> from RuleTree import RuleTreeClassifier >>> from RuleTree.stumps.classification import ObliqueProximityPivotTreeStumpClassifier >>> X, y = load_iris(return_X_y=True) >>> stump = ObliqueProximityPivotTreeStumpClassifier(random_state=0) >>> stump = stump.fit(X, y, context=None, node_id=None, cache=None) >>> stump.get_pivots()["discriminatives"] # up to 2 for each class [22, 41, 57, 72, 106, 118] >>> model = RuleTreeClassifier(max_depth=2, base_stumps=ObliqueProximityPivotTreeStumpClassifier()).fit(X, y)