fuzzyclust.models.HingingHyperplaneTree#
- class fuzzyclust.models.HingingHyperplaneTree(max_depth=3, min_samples_leaf=10, growth='balanced', max_leaves=None, tol_rmse=0.0, leaf_model='hinge', constrain_hinge=True, m=2.0, n_init=3, fcrm_max_iter=100, fcrm_tol=0.0001, random_state=None)[source]#
Bases:
RegressorMixin,BaseEstimatorBinary regression tree with hinging-hyperplane nodes identified by fuzzy c-regression.
A hinging hyperplane (Breiman 1993) is the continuous piecewise-linear function \(h(\mathbf{x}) = \max(\mathbf{x}_e^T\boldsymbol\theta_1,\ \mathbf{x}_e^T\boldsymbol\theta_2)\) (or \(\min\)) of two planes glued together along their intersection, the hinge \(\{\mathbf{x}: \mathbf{x}_e^T(\boldsymbol\theta_1-\boldsymbol\theta_2)=0\}\). Kenesei and Abonyi [1] observed that fuzzy c-regression with \(c=2\) identifies exactly two local linear models and their fuzzy operating regions, hence one hinge; the sign of the hinge function then splits the data into the two operating regions, each of which is modeled again by a hinge, and so on. The result is a binary tree whose internal nodes split along oblique hinges (no choice of a splitting variable is needed) and whose terminal nodes are hinge functions, i.e. a piecewise-linear model with \(2\times\) (number of leaves) affine pieces that is easy to use in model-based control.
- Parameters:
- max_depth
int, default=3 Depth of the tree (the root has depth 0).
- min_samples_leaf
int, default=10 A node is split only if both children receive at least this many samples.
- growth{“balanced”, “greedy”}, default=”balanced”
"balanced"grows every branch tomax_depth;"greedy"repeatedly splits the leaf with the largest sum of squared errors untilmax_leavesleaves exist (or no leaf can be split).- max_leaves
int,optional Number of leaves of the greedy tree (default \(2^{\text{max\_depth}}\)).
- tol_rmse
float, default=0.0 A node whose RMSE is below this value is not split further.
- leaf_model{“hinge”, “linear”}, default=”hinge”
Model stored in the terminal nodes.
"hinge"keeps the hinge function identified at the leaf (two affine pieces per leaf, as in [1]);"linear"replaces it by one least-squares plane fitted to the leaf’s data, which gives a classical piecewise-linear regression tree with oblique splits (the tree is grown with hinges in either case, the replacement happens after growing).- constrain_hingebool, default=True
Enforce the crossing constraint of [1] (eq. 11): the membership weighted centers of the two clusters must lie on opposite sides of the hinge, so that the hinge lies inside the operating region. When the unconstrained FCRM solution violates it, the local models are re-estimated by constrained (quadratic programming) weighted least squares in a few alternating-optimization steps.
- m
float, default=2.0 Fuzziness exponent of the fuzzy c-regression at every node.
- n_init
int, default=3 Number of random FCRM restarts per node (the best objective is kept).
- fcrm_max_iter
int, default=100 - fcrm_tol
float, default=1e-4 - random_state
int,RandomStateinstanceorNone, default=None
- max_depth
- Attributes:
Notes
At a node with data \(\{(\mathbf{x}_k, y_k)\}\) the fuzzy c-regression functional \(\sum_{i=1}^{2}\sum_k \mu_{ik}^m (y_k-\mathbf{x}_{e,k}^T\boldsymbol\theta_i)^2\) is minimized (weighted least squares for \(\boldsymbol\theta_i\), FCM update for \(\mu_{ik}\)). With \(\mathbf{v}_i\) the membership-weighted mean of the regressors of cluster \(i\), the hinge constraint \(\mathbf{v}_{e,1}^T(\boldsymbol\theta_1-\boldsymbol\theta_2)\) and \(\mathbf{v}_{e,2}^T(\boldsymbol\theta_1-\boldsymbol\theta_2)\) of opposite signs guarantees that the two planes cross inside the data. The hinge type (\(\max\) or \(\min\)) is the one with the smaller squared error on the node data; the samples where plane 1 is active go to the left child. The quality of the identification at a node is
\[\varrho = 1 - \frac{|m_1 - \sum_k \mu_{1k}|}{\sum_{i}\sum_k \mu_{ik}},\]with \(m_1\) the number of samples on the side of plane 1; a value close to one means that the crisp hinge split agrees with the fuzzy partition. Growing stops at
max_depth, when a child would be too small, when the error does not decrease, or when the node RMSE is belowtol_rmse.References
[1] (1,2,3)T. Kenesei, J. Abonyi, “Hinging hyperplane based regression tree identified by fuzzy clustering and its application”, Applied Soft Computing, 13(2), 782–792, 2013.
[2]L. Breiman, “Hinging hyperplanes for regression, classification and function approximation”, IEEE Trans. Information Theory, 39(3), 999–1013, 1993.
[3]R. J. Hathaway, J. C. Bezdek, “Switching regression models and fuzzy clustering”, IEEE Trans. Fuzzy Systems, 1(3), 195–204, 1993.
Examples
>>> from fuzzyclust.models import HingingHyperplaneTree, make_piecewise_linear >>> X, y = make_piecewise_linear(n_samples=300, random_state=0) >>> tree = HingingHyperplaneTree(max_depth=2, random_state=0).fit(X, y) >>> tree.n_leaves_ <= 4 and tree.score(X, y) > 0.95 True
Examples using fuzzyclust.models.HingingHyperplaneTree#
Hinging-hyperplane regression tree identified by fuzzy c-regression