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

Visualising Decision Tree explainer gives a Cytoscape object which is not savable to my local machine #522

Open
kaspersgit opened this issue Mar 19, 2024 · 2 comments

Comments

@kaspersgit
Copy link

In contrast with the linear models and EBM which give a Plotly Figure back when running .visualise() on an explainer object, the decision tree (classifier and regressor) give back a Cytoscape object. The plotly figure is downloadable but for the Cytoscape object I have not figured it out.

Is this difference on purpose?
Is there a way to download the decision tree explainer objects?

Code to show both objects:

import numpy as np
from sklearn.datasets import make_classification
from interpret.glassbox import ClassificationTree, ExplainableBoostingClassifier

# Generate fake classification data
X, y = make_classification(n_samples=1000, n_features=10, n_informative=3, n_redundant=2, random_state=42)

# Train an EBM model
ebm = ExplainableBoostingClassifier(random_state=42)
ebm.fit(X, y)

# Create a global explanation object
ebm_global_explanation = ebm.explain_global()

# Print the global explanation
print(ebm_global_explanation.visualize())

# Train an interpretable decision tree classifier
tree = ClassificationTree(random_state=42)
tree.fit(X, y)

# Create a global explanation object
tree_global_explanation = tree.explain_global()

# Print the global explanation
print(tree_global_explanation.visualize())
@paulbkoch
Copy link
Collaborator

Hi @kaspersgit -- @Harsha-Nori and @nopdive are the experts on this section of the code, but my limited understanding is that plotly was designed for X/Y plots, but not for directed graphs like a decision tree, so they used Cytoscape for that. I think the answer to your question about outputting them as text is that you can't, but I'll defer to Harsha and Sam on that one. You should be able to pickle them though I would think if you just wanted serialization.

@kaspersgit
Copy link
Author

That limitation of plotly makes sense.

In my use case I was looking for a way to save it as a regular project png (or similar) image file.

I hope Harsha or Sam have some suggestion on how to do this, it would help a lot!

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

No branches or pull requests

2 participants