BivariateTransformer#
- class BivariateTransformer(ml_task='clf', n_orientations=10, tree_params=None)[source]#
Bases:
ObliqueTransformerTransformer into oblique directions on a pair of features:
cos(a) * X_i + sin(a) * X_jforn_orientationsanglesabetween 0 and 180 degrees.The pair is chosen in
fit: for each pair of numerical features, a depth-1 decision tree of the task is fitted on its projections, and the pair with the highest gain is kept. The splitter then chooses the angle and the threshold. The projections are computed on the features as they are: scale the data beforehand if the features have different scales.- Parameters:
ml_task ({MODEL_TYPE_CLF, MODEL_TYPE_REG}, default=MODEL_TYPE_CLF) – Task of the stump, which determines the trees that choose the pair.
n_orientations (int, default=10) – Number of angles, evenly spaced in [0, 180) degrees.
tree_params (dict, default=None) – Parameters of the depth-1 decision trees that choose the pair (e.g.
criterion,random_state).
- Variables:
numerical (list of int) – Numerical columns of the feature matrix.
categorical (list of int) – Categorical columns of the feature matrix (none).
num_pre_transformed (list of int) – Numerical columns of the data.
coefficients (numpy.ndarray of shape (n_numerical_features, n_orientations)) – Coefficients of each direction: non-zero only on the chosen pair (only the chosen direction after
select).
See also
HouseholderTransformeroblique directions from a reflection of the principal component.
ObliqueDecisionTreeStumpClassifier,ObliqueDecisionTreeStumpRegressorExamples
>>> from sklearn.datasets import load_iris >>> from RuleTree.stumps.transformers import BivariateTransformer >>> X, y = load_iris(return_X_y=True) >>> transformer = BivariateTransformer(n_orientations=4, tree_params={"random_state": 0}) >>> transformer = transformer.fit(X, y, context=None, node_id=None, cache=None) >>> transformer.transform(X).shape # one column per angle (150, 4) >>> transformer.feature_id(1) # the chosen pair of features (0, 1)