LeafNode¶
LeafNode
¶
Bases: BaseNode
A terminal tree node holding the model used for its predictions.
Attributes:
| Name | Type | Description |
|---|---|---|
node_model |
LinearNodeModel
|
The prediction model for samples reaching this leaf. |
Source code in imote/nodes/leaf_node.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 | |
__init__(indices: np.ndarray, y_res: np.ndarray, rss: float, node_model: LinearNodeModel)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
ndarray
|
Row indices of the samples belonging to this node. |
required |
y_res
|
ndarray
|
Residuals of the target variable at this node. |
required |
rss
|
float
|
Residual sum of squares at this node. |
required |
node_model
|
LinearNodeModel
|
The prediction model for samples reaching this leaf. |
required |
Source code in imote/nodes/leaf_node.py
16 17 18 19 20 21 22 23 24 25 26 | |
get_children() -> List[BaseNode]
¶
Returns this node's children.
Returns:
| Type | Description |
|---|---|
List[BaseNode]
|
Empty list, a leaf node has no children. |
Source code in imote/nodes/leaf_node.py
28 29 30 31 32 33 34 | |
get_label() -> str
¶
Returns the full display label for this node.
Returns:
| Type | Description |
|---|---|
str
|
Label of the form "Leaf\n |
Source code in imote/nodes/leaf_node.py
36 37 38 39 40 41 42 | |
get_minimal_label() -> str
¶
Returns a short display label for this node.
Returns:
| Type | Description |
|---|---|
str
|
The string "L". |
Source code in imote/nodes/leaf_node.py
44 45 46 47 48 49 50 | |
to_dict() -> dict
¶
Serializes the node to a dictionary.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with base attributes plus the serialized node_model. |
Source code in imote/nodes/leaf_node.py
52 53 54 55 56 57 58 59 60 | |
from_dict(dic: dict) -> LeafNode
classmethod
¶
Reconstructs a LeafNode instance, including its model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic
|
dict
|
Dictionary previously produced by to_dict(). |
required |
Returns:
| Type | Description |
|---|---|
LeafNode
|
A new LeafNode instance with its node_model restored. |
Source code in imote/nodes/leaf_node.py
62 63 64 65 66 67 68 69 70 71 72 73 74 | |