pdstools.adm.trees._nodes¶
Tree primitives: split parsing, node dataclass, traversal helpers.
Attributes¶
Classes¶
Functions¶
|
Parse a tree-split string into a |
|
Yield every node in a tree in pre-order, root first. |
|
Walk a nested dict/list using the given key/index path; raise KeyError on miss. |
Module Contents¶
- SplitOperator¶
- _SPLIT_RE¶
- class Split¶
A parsed tree split condition.
- operator¶
Comparison operator:
"<"and">"for numeric thresholds,"=="for single-category equality,"in"for set membership,"is"for missing-value checks.- Type:
- value¶
Right-hand side of the split.
floatfor numeric thresholds,tuple[str, ...]forin-splits,strfor==/is.
- operator: SplitOperator¶
- parse_split(raw: str) Split¶
Parse a tree-split string into a
Split.Examples
>>> parse_split("Age < 42.5").operator '<' >>> sorted(parse_split("Color in { red, blue }").value) ['blue', 'red'] >>> parse_split("Status is Missing").value 'Missing'
- class Node¶
A single node in an AGB tree.
All nodes carry a
score(the leaf prediction or root prior). Internal nodes additionally carry a parsedSplitand again. Leaves havesplit=Noneandgain=0.0.
- _iter_nodes(tree: dict, depth: int = 1) collections.abc.Iterator[Node]¶
Yield every node in a tree in pre-order, root first.
Single source of truth for tree traversal. All metric computations consume this iterator instead of reimplementing recursion.
- Parameters:
- Return type: