tree
Node(child_left=-1, child_right=-1, split_feature=-2, split_feature_idx=-2, split_threshold=-2.0, samples=0)
dataclass
Represents a node in a TestTree.
Initializes a node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
child_left
|
int
|
Index of the left child node (-1 if leaf). |
-1
|
child_right
|
int
|
Index of the right child node (-1 if leaf). |
-1
|
split_feature
|
str | int
|
Feature used for splitting (-2 if leaf). |
-2
|
split_feature_idx
|
int
|
Index of the split feature (-2 if leaf). |
-2
|
split_threshold
|
float
|
Threshold value for splitting (-2.0 if leaf). |
-2.0
|
samples
|
int
|
Number of samples reaching this node (0 if not a leaf). |
0
|
Source code in src/flowcean/testing/generator/ddtig/domain/model_analyser/base/tree.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
TestTree(model_tree, specs_handler)
dataclass
Represents a tree structure used for generating test inputs.
Attributes:
test_tree: dict Dictionary representing the structure of a River or scikit-learn tree.
Methods:
get_n_samples() Returns the total number of samples used to train the tree.
Initializes the TestTree from a model tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_tree
|
HoeffdingTreeRegressor | HoeffdingTreeClassifier | Tree
|
A River or scikit-learn decision tree. |
required |
specs_handler
|
SystemSpecsHandler
|
Object for accessing feature specifications. |
required |
Source code in src/flowcean/testing/generator/ddtig/domain/model_analyser/base/tree.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
get_n_samples()
Returns the total number of samples used to train the tree.
Returns:
| Type | Description |
|---|---|
int
|
Total number of samples. |
Source code in src/flowcean/testing/generator/ddtig/domain/model_analyser/base/tree.py
213 214 215 216 217 218 219 220 221 222 223 | |
convert_river_tree(river_tree, feature_dict)
Extract the structure of a River Hoeffding tree.
Store the extracted structure in a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
river_tree
|
HoeffdingTreeRegressor | HoeffdingTreeClassifier
|
A River Hoeffding tree. |
required |
feature_dict
|
dict
|
Dictionary mapping feature names to their indices. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary representing the tree structure. |
Source code in src/flowcean/testing/generator/ddtig/domain/model_analyser/base/tree.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
convert_sklearn_tree(sklearn_tree, feature_dict)
Extract the structure of a scikit-learn decision tree.
Store the extracted structure in a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sklearn_tree
|
Tree
|
A scikit-learn decision tree. |
required |
feature_dict
|
dict
|
Dictionary mapping feature indices to feature names. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary representing the tree structure. |
Source code in src/flowcean/testing/generator/ddtig/domain/model_analyser/base/tree.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |