dmlc / XGBoost.jl

XGBoost Julia Package
Other
288 stars 110 forks source link

Display split conditions for all nodes in Term.Tree #141

Closed co2chicken closed 1 year ago

co2chicken commented 1 year ago

Term.Tree() view is missing important information for every node, the split condition. Because the split condition is missing, the tree has almost no useful value. See the comparison of the old(top) and proposed(bottom) below:

image

In the top, it is impossible to know how to navigate through the tree with values for x1 and x2, while it is possible on the bottom.

ExpandingMan commented 1 year ago

Thanks! This is definitely an improvement.

Is there any reason not to do this just by modifying _tree_display_branch_string? For example

function _tree_display_branch_string(node, j::Integer)
    if node.yes == node.id
        string(node.split, " < ", round(node.split_condition, digits=3))
    else
        string(node.split, " ≥ ", round(node.split_condition, digits=3))
    end
end

(and call as _tree_display_branch_string(ch[j], j))

One advantage of this would be maintaining proper type inference for the collection type.

ExpandingMan commented 1 year ago

Superseded by #162