-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
Is there any component to show prediction for multiple subjects #85
Comments
Hi Saman, Such a component currently does not exist. It shouldn't be too hard to make though. You would need to combine an index selector with a dash datatable (https://dash.plotly.com/datatable), and some callbacks connecting the index selector to the datatable by adding a row of data. So something like this: from dash_table import DataTable
class PredictionTable(ExplainerComponent):
def __init__(self, explainer, title="Prediction Table", name=None,
hide_index=False, hide_table=False, index=None):
super().__init__(explainer)
def layout(self):
return dbc.Container([
dbc.Row([
make_hideable(
dbc.Col([
dbc.Label(f"{self.explainer.index_name}:", id='predictions-table-index-label-'+self.name),
dbc.Tooltip(f"Select the {self.explainer.index_name} to display the feature contributions for",
target='predictions-table-index-label-'+self.name),
dcc.Dropdown(id='predictions-table-index-'+self.name,
options = [{'label': str(idx), 'value':idx}
for idx in self.explainer.get_index_list()],
value=self.index)
], md=4), hide=self.hide_index),
]),
dbc.Row([
make_hideable(
dbc.Col([
DataTable(
id='predictions-table-table-'+self.name,
columns=[{"name": i, "id": i} for i in
(self.explainer.merged_cols.tolist()+['prediction'])],
data=None,
),
]), hide=self.hide_table),
])
])
def component_callbacks(self, app):
@app.callback(
Output('predictions-table-table-'+self.name, 'data'),
[Input('predictions-table-index-'+self.name, 'value')],
[State('predictions-table-table-'+self.name, 'data')])
def update_predictions_table(index, data):
if index is not None:
X_row = self.explainer.get_X_row(index, merge=True)
X_row['prediction'] = self.explainer.preds[explainer.get_idx(index)]
if data is not None:
data.append(X_row.to_dict('records')[0])
return data
else:
return X_row.to_dict('records')
raise PreventUpdate
ExplainerDashboard(explainer, PredictionTable, mode='external').run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Is there any component in explainerdashboard to show prediction for multiple subjects along with input features (e.g., in a table form)? if not, do you have any recommendations for displaying a data frame in a tab?
Thanks,
Saman
The text was updated successfully, but these errors were encountered: