1 | <?php |
||
9 | class DecisionTreeLeaf |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | public $value; |
||
15 | |||
16 | /** |
||
17 | * @var float |
||
18 | */ |
||
19 | public $numericValue; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | public $operator; |
||
25 | |||
26 | /** |
||
27 | * @var int |
||
28 | */ |
||
29 | public $columnIndex; |
||
30 | |||
31 | /** |
||
32 | * @var DecisionTreeLeaf |
||
33 | */ |
||
34 | public $leftLeaf = null; |
||
35 | |||
36 | /** |
||
37 | * @var DecisionTreeLeaf |
||
38 | */ |
||
39 | public $rightLeaf= null; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | public $records = []; |
||
45 | |||
46 | /** |
||
47 | * Class value represented by the leaf, this value is non-empty |
||
48 | * only for terminal leaves |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | public $classValue = ''; |
||
53 | |||
54 | /** |
||
55 | * @var bool |
||
56 | */ |
||
57 | public $isTerminal = false; |
||
58 | |||
59 | /** |
||
60 | * @var bool |
||
61 | */ |
||
62 | public $isContinuous = false; |
||
63 | |||
64 | /** |
||
65 | * @var float |
||
66 | */ |
||
67 | public $giniIndex = 0; |
||
68 | |||
69 | /** |
||
70 | * @var int |
||
71 | */ |
||
72 | public $level = 0; |
||
73 | |||
74 | /** |
||
75 | * @param array $record |
||
76 | * @return bool |
||
77 | * @throws InvalidArgumentException |
||
78 | */ |
||
79 | public function evaluate($record) |
||
109 | |||
110 | /** |
||
111 | * Returns Mean Decrease Impurity (MDI) in the node. |
||
112 | * For terminal nodes, this value is equal to 0 |
||
113 | * |
||
114 | * @param int $parentRecordCount |
||
115 | * |
||
116 | * @return float |
||
117 | */ |
||
118 | public function getNodeImpurityDecrease(int $parentRecordCount) |
||
139 | |||
140 | /** |
||
141 | * Returns HTML representation of the node including children nodes |
||
142 | * |
||
143 | * @param $columnNames |
||
144 | * @return string |
||
145 | */ |
||
146 | public function getHTML($columnNames = null) |
||
182 | |||
183 | /** |
||
184 | * HTML representation of the tree without column names |
||
185 | * |
||
186 | * @return string |
||
187 | */ |
||
188 | public function __toString() |
||
192 | } |
||
193 |