neural_trees.MultivariateDecisionTree#
- class neural_trees.MultivariateDecisionTree(max_depth: int = 4, min_samples_split: int = 10, min_samples_leaf: int = 3, min_impurity_decrease: float = 0.0, random_state: int | None = None)[source]#
Bases:
ClassifierMixin,BaseEstimatorMultivariate Decision Tree Classifier (sklearn-compatible).
Each internal node splits on a linear combination of all features, w . x + b > 0, where w is a linear discriminant fitted on the samples reaching that node. Boundaries are oblique rather than axis-aligned, so correlated features are handled in one node instead of a staircase of univariate cuts.
- Parameters:
- max_depthint, default=4
Maximum depth of the tree.
- min_samples_splitint, default=10
Minimum samples required to attempt a split at a node.
- min_samples_leafint, default=3
Minimum samples that must land on each side of a split.
- min_impurity_decreasefloat, default=0.0
Minimum weighted Gini decrease required to keep a split.
- random_stateint or None, default=None
Seed for the centroid clustering used to build two-group problems when a node holds more than two classes.
- Attributes:
- classes_ndarray of shape (n_classes,)
- n_features_in_int
- root_internal node object
- tree_depth_int
Depth actually reached after fitting.
- n_nodes_int
Number of internal (splitting) nodes.
References
Alpaydın, E., & Çetin, Ü. (1995). Multivariate Statistical Techniques for Constructive Induction. Yıldız, O. T., & Alpaydın, E. (2001). Omnivariate Decision Trees. IEEE TNN.
Examples
>>> from neural_trees import MultivariateDecisionTree >>> from sklearn.datasets import load_wine >>> X, y = load_wine(return_X_y=True) >>> mdt = MultivariateDecisionTree(max_depth=3, random_state=0) >>> mdt.fit(X, y) >>> mdt.score(X, y)
- fit(X, y) MultivariateDecisionTree[source]#
Fit the multivariate tree.
- Parameters:
- Xarray-like of shape (n_samples, n_features)
- yarray-like of shape (n_samples,)
- Returns:
- self
- get_split_weights() List[Tuple[ndarray, float]][source]#
Return the hyperplane of every internal node as (w, b) pairs, in pre-order. Useful for reading off which features drive a split.
- predict(X) ndarray[source]#
Predict class labels.
- Parameters:
- Xarray-like of shape (n_samples, n_features)
- Returns:
- y_predndarray of shape (n_samples,)
- predict_proba(X) ndarray[source]#
Predict class probabilities from the reached leaf’s class distribution.
- Parameters:
- Xarray-like of shape (n_samples, n_features)
- Returns:
- probandarray of shape (n_samples, n_classes)
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MultivariateDecisionTree#
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter inscore.
- Returns:
- selfobject
The updated object.