---
# System prepended metadata

title: Tree system design review

---

# Tree system design review


```plantuml


package _tree.pyx {

    struct StackRecord

    class Tree


    abstract TreeBuilder {
    }
    class DepthFirstTreeBuilder {
        splitter
        build(tree, X, y, sample_weight=None)
    }
    class BestFirstTreeBuilder {
        splitter
        build(tree, X, y, sample_weight=None)
    }

    TreeBuilder <|-down- DepthFirstTreeBuilder
    TreeBuilder <|-down- BestFirstTreeBuilder
}

```



```plantuml

package _splitter.pyx {
    class Partitioner 
    class SparsePartitioner
    class DensePartitioner
    Partitioner -up-> SparsePartitioner
    Partitioner -up-> DensePartitioner

    abstract Splitter {
        criterion
        init()
        node_reset()
        node_value()
        node_impurity()
    }
    class RandomSplitter {
        node_split()
    }
    class RandomSparseSplitter {
        node_split()
    }
    class BestSplitter {
        node_split()
    }
    class BestSparseSplitter {
        node_split()
    }

    Splitter <|-down- RandomSplitter
    Splitter <|-down- RandomSparseSplitter
    Splitter <|-down- BestSplitter
    Splitter <|-down- BestSparseSplitter


    RandomSparseSplitter *-- SparsePartitioner
    BestSparseSplitter *-- SparsePartitioner
    RandomSplitter *-- DensePartitioner
    BestSplitter *-- DensePartitioner
}
```

```plantuml
package _criterion.pyx {
    class Criterion {
        impurity_improvement()
        proxy_impurity_improvement()
    }
    class ClassificationCriterion {
        sum_total
        sum_left
        sum_right
        max_n_classes
        init()
        reset()
        update()
        node_value()
    }
    class Entropy {
        node_impurity()
        children_impurity()
    }
    class Gini {
        node_impurity()
        children_impurity()
    }
    class RegressionCriterion {
        sum_total
        sum_left
        sum_right
        init()
        reset()
        update()
        node_value()
    }
    class MSE {
        node_impurity()
        proxy_impurity_improvement()
        children_impurity()
    }
    class MAE {
        init()
        reset()
        update()
        node_value()
        node_impurity()
        children_impurity()
    }
    class FriedmanMSE {
        proxy_impurity_improvement()
        impurity_improvement()
    }
    class Poisson {
        node_impurity()
        proxy_impurity_improvement()
        children_impurity()
    }
    
    Criterion <|-down- ClassificationCriterion
    Criterion <|-down- RegressionCriterion
    ClassificationCriterion <|-down- Entropy
    ClassificationCriterion <|-down- Gini
    RegressionCriterion <|-down- MSE
    RegressionCriterion <|-down- MAE
    RegressionCriterion <|-down- FriedmanMSE
    RegressionCriterion <|-down Poisson
    
}
```