Closed mepland closed 1 year ago
Thank you for finding this issue! You are correct these do not match and something is amiss...I would guess the issue is with the visualization code not the print_tree
method.
@OmerRonen Have you seen this disagreement before?
In imodels_demo.ipynb the Tree #0 returned by printing the fitted model:
and plotting:
do not agree!
Based on
_tree_to_str_with_data
, which agrees with the simpler_tree_to_str
actually being called here - see below, the first line printed after a split is the left / true branch, while the second line after the split is the right / false branch.Reading the printed version, after the first "Glucose concentration test <= 99.500" split, there should be a leaf with value 0.068 for <= 99.5, and then the "Glucose concentration test <= 168.500" split for > 99.5, but this is not the structure of the plotted tree. Also, note that both of the "Blood pressure(mmHg)" splits should end in leaves, while in the plot one of them leads to a "#Pregnant" split.
The output of
print(figs.print_tree(X_train, y_train))
is shown below for reference:Also see my stripped down notebook demonstrating the issue here.