value = 1;
$leaf->columnIndex = 0;
$rightLeaf = new DecisionTreeLeaf();
$rightLeaf->value = '<= 2';
$rightLeaf->columnIndex = 1;
$leaf->rightLeaf = $rightLeaf;
$this->assertEquals('
', $leaf->getHTML());
}
public function testNodeImpurityDecreaseShouldBeZeroWhenLeafIsTerminal(): void
{
$leaf = new DecisionTreeLeaf();
$leaf->isTerminal = true;
$this->assertEquals(0.0, $leaf->getNodeImpurityDecrease(1));
}
public function testNodeImpurityDecrease(): void
{
$leaf = new DecisionTreeLeaf();
$leaf->giniIndex = 0.5;
$leaf->records = [1, 2, 3];
$leaf->leftLeaf = new DecisionTreeLeaf();
$leaf->leftLeaf->records = [5, 2];
$leaf->rightLeaf = new DecisionTreeLeaf();
$leaf->rightLeaf->records = [];
$leaf->rightLeaf->giniIndex = 0.3;
$this->assertSame(0.75, $leaf->getNodeImpurityDecrease(2));
}
}