Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using dataset that is different from the training for trees models - does not draw #298

Open
StepanWorkV opened this issue Jun 2, 2023 · 1 comment

Comments

@StepanWorkV
Copy link
Contributor

StepanWorkV commented Jun 2, 2023

# when using another dataset than the training dataset, some leaves could have 0 samples.

if sum(counts) == 0:

Example:

Would work just fine

viz = DTreeVizAPI(
  ShadowDecTree.get_shadow_tree(
        decision_tree,
        X_train, <--- Train Data
        y_train,
        feature_names=X_train.columns.tolist(),
        target_name="target",
        class_names=labels,
    )
)

vw = viz.view(
    x=X_train.iloc[index],
    fancy=False,
    show_node_labels=False,
    show_just_path=False,
)

This would fail because of the issue described in the comment. Some nodes will not be generated, however, their file paths will be written into SVG file. When passing to graphviz later, this would error due to "file not found" for those missing plots.

viz = DTreeVizAPI(
  ShadowDecTree.get_shadow_tree(
        decision_tree,
        X_sample, <--- Some sample data that might not have all the leaves 
        y_sample,
        feature_names=X_sample.columns.tolist(),
        target_name="target",
        class_names=labels,
    )
)

vw = viz.view(
    x=X_sample.iloc[index],
    fancy=False,
    show_node_labels=False,
    show_just_path=False,
)
@tlapusan
Copy link
Collaborator

tlapusan commented Jun 7, 2023

Hi @StepanWorkV, I do remember that this was solved. I have to look into the code/history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants