Comments (3)
Hello, and sorry for the late response. I think I didn't explain properly what the problem was. What I want to do basically is to update the plot ShapSummaryComponent with a callback in my custom tab. Whenever I select an area in the preds_map, a new explainer should be created with the filtered data within the map, changing the calculated shap values of the features. WIth this new explainer, I would like to update the ShapSummaryComponent in order to provide insights about particular areas and which features had the biggest impact in these specific areas. Is this possible? Thanks in advance.
UPDATE: I managed to do it. What I did was basically use a callback in my map that recalculates the shap values for the selected area, re calculates the explainer and sets the new explainer for the shap summary component and updates a hidden "P" html element once its finished its calculations.
Then I added in the update_shap_summary_graph another input with this element that I named "shap-hidden-trigger" and every time this element changes, the callback is called again with the new explainer.
shap_components.py
@app.callback(
[
Output("shap-summary-graph-" + self.name, "figure"),
Output("shap-summary-index-col-" + self.name, "style"),
],
[
Input("shap-summary-type-" + self.name, "value"),
Input("shap-summary-depth-" + self.name, "value"),
Input("shap-summary-index-" + self.name, "value"),
Input("pos-label-" + self.name, "value"),
Input("shap-hidden-trigger", "children"),
],
)
def update_shap_summary_graph(summary_type, depth, index, pos_label, hidden_trigger):
#rest of the code
my_custom_layout.py
@app.callback(
Output('shap-hidden-trigger', 'children'),
Input('update-shap-button', 'n_clicks'),
State('preds-map', 'selectedData'),
prevent_initial_call=True,
)
def update_shap_summary(change_settings, selectedData):
#some processing of the data that I skipped
shap_explainer = shap.Explainer(predictor)
shap_values = shap_explainer.shap_values(
new_X,
check_additivity=False,
approximate=False
)
base_values = shap_explainer.expected_value
new_explainer = ClassifierExplainer(model=predictor, X=new_X, n_jobs=-1, index_name="Block ID",
precision="float32", target="DEPVAR")
new_explainer.set_shap_values(base_values, shap_values)
self.shap_summary.explainer = new_explainer
return "Turing" #just updating to whatever since its hidden
Thanks!
from explainerdashboard.
Please show a screenshot or copy of the error you get, once we can see what your output is I could pair program with you to see if I can help.
from explainerdashboard.
It looks like you are reinstantiating all the sub components every time there is an update? I don't think that will work. All the components have to be there at the start of the dash app, and then the callbacks update the properties of the components, so the self.update_components() line is probably that breaks things. So get rid of that. The shap values have already been pre-calculated in the explainer that gets passed to the component, so you never reinstantiate the explainer and then recalculate.
So the callback should probably target Output('preds_map', 'figure')
instead and then you simply generate the right plot for a subsample.
from explainerdashboard.
Related Issues (20)
- Dashboard loading stuck in docker
- Categorical columns HOT 3
- Add support for string labels
- support for pandas 2.0 HOT 2
- whatif component customization limiting range and rounding off decimal value
- Add support for CalibratedClassifierCV algorithm
- Support for GPUTree HOT 5
- ImportError: cannot import name 'dtreeviz' from 'dtreeviz.trees' HOT 2
- ValueError: Must pass 2-d input. HOT 1
- Showcase in a HuggingFace space? HOT 1
- Dashboard is not running correctly when I am trying to use saved joblib file. HOT 3
- Dashboards not loading from saved yaml, joblib files. HOT 2
- Speed up Dashboard joblib/yaml export HOT 3
- skorch models raising The SHAP explanations do not sum up to the model's output
- integration tests failing due dash_duo.get_logs() returning None HOT 1
- Aggregated SHAP values for one hot encoded features are overestimated
- Logodds: difference between contributions plot and prediction box
- Unexplained running out of RAM memory with ensemble voting classifier model
- shap_values should be 2d, instead shape=(200, 21, 2)! HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from explainerdashboard.