Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
39 | public function __construct(int $column, $value, array $groups, float $impurity) |
||
40 | { |
||
41 | if (count($groups) !== 2) { |
||
42 | throw new InvalidArgumentException('The number of groups must be exactly two.'); |
||
43 | } |
||
44 | |||
45 | if ($impurity < 0.) { |
||
46 | throw new InvalidArgumentException('Impurity cannot be less than 0.'); |
||
47 | } |
||
48 | |||
49 | $this->column = $column; |
||
50 | $this->value = $value; |
||
51 | $this->groups = $groups; |
||
52 | $this->impurity = $impurity; |
||
53 | $this->samplesCount = (int) array_sum(array_map(static function (array $group): int { |
||
54 | return count($group[0]); |
||
55 | }, $groups)); |
||
56 | } |
||
108 |