format_split_path

format_split_path(
    item_index,
    split_keywords,
    tree,
    leaf_batches,
    children_map,
    *,
    top_k=3,
)

Return the keyword path for a single item from root to leaf.

Traces which child the item belongs to at each split level and returns the top-k keywords for that child.

Parameters

Name Type Description Default
item_index int The item’s index in the dataset. required
split_keywords dict Output of compute_split_keywords(). required
tree list[TreeNode] Tree structure list. required
leaf_batches dict[int, np.ndarray] {node_id: item_indices}. required
children_map dict[int, list[int]] {parent_id: [child_ids]}. required
top_k int Number of keywords per path step. 3

Returns

Name Type Description
list[str] List of comma-separated keyword strings, one per split level.
list[str] E.g.: [“screw,plate,fixation”, “pedicle,cervical,spine”]