interpret icon indicating copy to clipboard operation
interpret copied to clipboard

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

Open kaspersgit opened this issue 2 years ago • 4 comments

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())

kaspersgit avatar Mar 19 '24 21:03 kaspersgit

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.

paulbkoch avatar Mar 21 '24 19:03 paulbkoch

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!

kaspersgit avatar Mar 21 '24 20:03 kaspersgit

Hey @Harsha-Nori and @nopdive , is this something you have on your list to look into?

kaspersgit avatar Aug 12 '24 21:08 kaspersgit

Closing this issue, since we aren't planning on replacing the Cytoscape implementation.

paulbkoch avatar May 12 '26 23:05 paulbkoch