protected function terminate(Labeled $dataset) : BinaryNode
    {
        $n = $dataset->numRows();

        $labels = $dataset->labels();

        $counts = array_count_values($labels);

        $outcome = argmax($counts);

        $probabilities = [];

        foreach ($counts as $class => $count) {
            $probabilities[$class] = $count / $n;
        }

        $impurity = 1. - (max($counts) / $n) ** 2;

        return new Outcome($outcome, $probabilities, $impurity, $n);
    }
protected function terminate(Labeled $dataset) : BinaryNode
    {
        $n = $dataset->numRows();

        $labels = $dataset->labels();

        $counts = array_count_values($labels);

        $outcome = argmax($counts);

        $probabilities = [];

        foreach ($counts as $class => $count) {
            $probabilities[$class] = $count / $n;
        }

        $impurity = 1. - (max($counts) / $n) ** 2;

        return new Outcome($outcome, $probabilities, $impurity, $n);
    }
protected function terminate ( Labeled $ dataset ) : BinaryNode { $ n = $ dataset -> numRows ( ) ; $ labels = $ dataset -> labels ( ) ; $ counts = array_count_values ( $ labels ) ; $ outcome = argmax ( $ counts ) ; $ probabilities = [ ] ; foreach ( $ counts as $ class => $ count ) { $ probabilities [ $ class ] = $ count / $ n ; } $ impurity = 1. - ( max ( $ counts ) / $ n ) ** 2 ; return new Outcome ( $ outcome , $ probabilities , $ impurity , $ n ) ; }
Terminate the branch by selecting the class outcome with the highest
probability.

@param \Rubix\ML\Datasets\Labeled $dataset
@return \Rubix\ML\Graph\Nodes\BinaryNode
Terminate the branch by selecting the class outcome with the highest probability .