protected function getSplitNodesByColumn(int $column, DecisionTreeLeaf $node): array
    {
        if ($node->isTerminal) {
            return [];
        }

        $nodes = [];
        if ($node->columnIndex === $column) {
            $nodes[] = $node;
        }

        $lNodes = [];
        $rNodes = [];
        if ($node->leftLeaf !== null) {
            $lNodes = $this->getSplitNodesByColumn($column, $node->leftLeaf);
        }

        if ($node->rightLeaf !== null) {
            $rNodes = $this->getSplitNodesByColumn($column, $node->rightLeaf);
        }

        return array_merge($nodes, $lNodes, $rNodes);
    }
protected function getSplitNodesByColumn(int $column, DecisionTreeLeaf $node): array
    {
        if ($node->isTerminal) {
            return [];
        }

        $nodes = [];
        if ($node->columnIndex === $column) {
            $nodes[] = $node;
        }

        $lNodes = [];
        $rNodes = [];
        if ($node->leftLeaf !== null) {
            $lNodes = $this->getSplitNodesByColumn($column, $node->leftLeaf);
        }

        if ($node->rightLeaf !== null) {
            $rNodes = $this->getSplitNodesByColumn($column, $node->rightLeaf);
        }

        return array_merge($nodes, $lNodes, $rNodes);
    }
protected function getSplitNodesByColumn ( int $ column , DecisionTreeLeaf $ node ) : array { if ( $ node -> isTerminal ) { return [ ] ; } $ nodes = [ ] ; if ( $ node -> columnIndex === $ column ) { $ nodes [ ] = $ node ; } $ lNodes = [ ] ; $ rNodes = [ ] ; if ( $ node -> leftLeaf !== null ) { $ lNodes = $ this -> getSplitNodesByColumn ( $ column , $ node -> leftLeaf ) ; } if ( $ node -> rightLeaf !== null ) { $ rNodes = $ this -> getSplitNodesByColumn ( $ column , $ node -> rightLeaf ) ; } return array_merge ( $ nodes , $ lNodes , $ rNodes ) ; }
Collects and returns an array of internal nodes that use the given
column as a split criterion
Collects and returns an array of internal nodes that use the given column as a split criterion