InternalNode¶
InternalNode
¶
Bases: BaseNode, ABC
Abstract base for all internal nodes.
Attributes:
| Name | Type | Description |
|---|---|---|
pivot_idx |
int
|
Index of the feature this node acts on. |
Source code in imote/nodes/internal_node.py
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 | |
__init__(indices: np.ndarray, y_res: np.ndarray, pivot_idx: int)
¶
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 |
pivot_idx
|
int
|
Index of the feature this node acts on. |
required |
Source code in imote/nodes/internal_node.py
18 19 20 21 22 23 24 25 26 | |
get_minimal_label(fmt: LabelFormatter) -> str
¶
Returns a short display label for this node.
Returns:
| Type | Description |
|---|---|
str
|
String of minimal label, used when space is limited. |
Source code in imote/nodes/internal_node.py
28 29 30 31 32 33 34 | |
set_children(children: List[BaseNode])
abstractmethod
¶
Replaces this node's children.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
List[BaseNode]
|
New child node(s), in the same order as returned by get_children(). |
required |
Source code in imote/nodes/internal_node.py
36 37 38 39 40 41 42 43 44 | |
LinearNode
¶
Bases: InternalNode
LIN: Single child node that applies a linear model..
Attributes:
| Name | Type | Description |
|---|---|---|
linear_model |
SimpleLinearNodeModel
|
Single-feature linear model applied at this node. |
child |
BaseNode
|
The node's single child. |
Source code in imote/nodes/internal_node.py
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 88 89 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 129 130 131 132 | |
__init__(indices: np.ndarray, y_res: np.ndarray, pivot_idx: int, linear_model: SimpleLinearNodeModel, child: BaseNode)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
ndarray
|
Row indices of the samples associated with this node. |
required |
y_res
|
ndarray
|
Residuals of the target variable at this node. |
required |
pivot_idx
|
int
|
Index of the feature the linear term is based on. |
required |
linear_model
|
SimpleLinearNodeModel
|
One dimensional linear model applied at this node. |
required |
child
|
BaseNode
|
The node's single child. |
required |
Source code in imote/nodes/internal_node.py
58 59 60 61 62 63 64 65 66 67 68 69 70 | |
get_children() -> List[BaseNode]
¶
Returns this node's single child.
Returns:
| Type | Description |
|---|---|
List[BaseNode]
|
List containing the child node. |
Source code in imote/nodes/internal_node.py
72 73 74 75 76 77 78 | |
set_children(children: List[BaseNode])
¶
Replaces this node's child.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
List[BaseNode]
|
List containing exactly one new child node. |
required |
Source code in imote/nodes/internal_node.py
80 81 82 83 84 85 86 | |
get_label(fmt: LabelFormatter) -> str
¶
Returns the full display label for this node.
Returns:
| Type | Description |
|---|---|
str
|
Label of the form "LIN\n |
Source code in imote/nodes/internal_node.py
88 89 90 91 92 93 94 | |
get_description(fmt: LabelFormatter) -> str
¶
Returns the linear model of this node.
Source code in imote/nodes/internal_node.py
96 97 98 | |
to_dict() -> dict
¶
Serializes the node to a dictionary.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with base attributes plus pivot_idx, linear_model, |
dict
|
and the child's class name and serialized form. |
Source code in imote/nodes/internal_node.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
from_dict(dic: dict) -> LinearNode
classmethod
¶
Reconstructs a LinearNode instance, including its child.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic
|
dict
|
Dictionary previously produced by to_dict(). |
required |
Returns:
| Type | Description |
|---|---|
LinearNode
|
A new LinearNode instance with its child restored. |
Source code in imote/nodes/internal_node.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |