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

fixes dbc.RadioButton bug #214

Merged
merged 12 commits into from
May 6, 2022
Prev Previous commit
Next Next commit
migration to bootstrap 5
Achim Gädke committed Apr 17, 2022

Unverified

This user has not yet uploaded their public signing key.
commit c37ea5cfb9c2fffb7207f5544b1927beedcc314c
85 changes: 43 additions & 42 deletions explainerdashboard/dashboard_components/classifier_components.py
Original file line number Diff line number Diff line change
@@ -130,25 +130,23 @@ def layout(self):
]), hide=self.hide_title),
dbc.CardBody([
dbc.Row([
dbc.Col([
make_hideable(
dbc.Col([
self.selector.layout()
], md=2), hide=self.hide_selector),
])
]),
dbc.Row([
make_hideable(
dbc.Col([
self.index_selector.layout()
], md=8), hide=self.hide_index),
], width=8, md=8), hide=self.hide_index),
make_hideable(
dbc.Col([
dbc.Button(f"Random {self.explainer.index_name}", color="primary", id='random-index-clas-button-'+self.name, block=True),
dbc.Button(f"Random {self.explainer.index_name}", color="primary", id='random-index-clas-button-'+self.name),
dbc.Tooltip(f"Select a random {self.explainer.index_name} according to the constraints",
target='random-index-clas-button-'+self.name),
], md=4), hide=self.hide_button),
], form=True, style=dict(marginBottom=10)),
], width=4, md=4), hide=self.hide_button),
], class_name="mb-2"),
dbc.Row([
make_hideable(
dbc.Col([
@@ -161,27 +159,30 @@ def layout(self):
options=[{'label': lab, 'value': lab} for lab in self.explainer.labels],
multi=True,
value=self.labels),
], md=8), hide=self.hide_labels),
], width=8, md=8), hide=self.hide_labels),
make_hideable(
dbc.Col([
html.Div([
dbc.Label("Range:", html_for='random-index-clas-pred-or-perc-'+self.name),
dbc.Select(
id='random-index-clas-pred-or-perc-'+self.name,
options=[
{'label': 'probability', 'value': 'predictions'},
{'label': 'percentile', 'value': 'percentiles'},
],
value=self.pred_or_perc)
], id='random-index-clas-pred-or-perc-div-'+self.name),
dbc.Tooltip("Instead of selecting from a range of predicted probabilities "
"you can also select from a range of predicted percentiles. "
"For example if you set the slider to percentile (0.9-1.0) you would"
f" only sample random {self.explainer.index_name} from the top "
"10% highest predicted probabilities.",
target='random-index-clas-pred-or-perc-div-'+self.name),
], md=4), hide=self.hide_pred_or_perc),
], style=dict(marginBottom=10)),
dbc.Label(
"Range:", html_for='random-index-clas-pred-or-perc-'+self.name),
dbc.Select(
id='random-index-clas-pred-or-perc-'+self.name,
options=[
{'label': 'probability',
'value': 'predictions'},
{'label': 'percentile',
'value': 'percentiles'},
],
value=self.pred_or_perc),
dbc.Tooltip("Instead of selecting from a range of predicted probabilities "
"you can also select from a range of predicted percentiles. "
"For example if you set the slider to percentile (0.9-1.0) you would"
f" only sample random {self.explainer.index_name} from the top "
"10% highest predicted probabilities.",
target='random-index-clas-pred-or-perc-div-'+self.name),
], width=4,
id='random-index-clas-pred-or-perc-div-'+self.name),
hide=self.hide_pred_or_perc),
], class_name="mb-2"),
dbc.Row([
make_hideable(
dbc.Col([
@@ -204,7 +205,7 @@ def layout(self):
]), hide=self.hide_slider),
], justify="start"),
]),
])
], class_name="h-100")

def to_html(self, state_dict=None, add_header=True):
args = self.get_state_args(state_dict)
@@ -358,7 +359,7 @@ def layout(self):
]), hide=self.hide_piechart),
]),
])
])
], class_name="h-100")

def _format_preds_df(self, preds_df):
preds_df.probability = np.round(100*preds_df.probability.values, self.round).astype(str)
@@ -613,7 +614,7 @@ def layout(self):
], width=4), hide=self.hide_binmethod),
make_hideable(
dbc.Col([
dbc.FormGroup([
dbc.Row([
dbc.Label("Multi class:", id="precision-multiclass-label-"+self.name),
dbc.Tooltip("Display the observed proportion for all class"
" labels, not just positive label.",
@@ -629,7 +630,7 @@ def layout(self):
], width=4), hide=self.hide_multiclass),
]),
]), hide=self.hide_footer)
])
], class_name="h-100")

def to_html(self, state_dict=None, add_header=True):
args = self.get_state_args(state_dict)
@@ -804,7 +805,7 @@ def layout(self):
], style={'margin-bottom': 25}), hide=self.hide_cutoff),
make_hideable(
html.Div([
dbc.FormGroup([
dbc.Row([
#dbc.Label("Percentage:", id='confusionmatrix-percentage-label-'+self.name),
dbc.Tooltip("Highlight the percentage in each cell instead of the absolute numbers",
target='confusionmatrix-percentage-'+self.name),
@@ -819,7 +820,7 @@ def layout(self):
]), hide=self.hide_percentage),
make_hideable(
html.Div([
dbc.FormGroup([
dbc.Row([
dbc.Label("Normalisation:"),
dbc.Tooltip("Normalize the percentages in the confusion matrix over the true observations, predicted values or overall",
target='confusionmatrix-normalize-'+self.name),
@@ -837,7 +838,7 @@ def layout(self):
]), hide=self.hide_normalize),
make_hideable(
html.Div([
dbc.FormGroup([
dbc.Row([
dbc.Label("Binary:", id='confusionmatrix-binary-label-'+self.name),
dbc.Tooltip("display a binary confusion matrix of positive "
"class vs all other classes instead of a multi"
@@ -853,7 +854,7 @@ def layout(self):
]),
]), hide=self.hide_binary),
]), hide=self.hide_footer)
])
], class_name="h-100")

def to_html(self, state_dict=None, add_header=True):
args = self.get_state_args(state_dict)
@@ -988,7 +989,7 @@ def layout(self):
], style={'margin-bottom': 25}), hide=self.hide_cutoff),
make_hideable(
html.Div([
dbc.FormGroup([
dbc.Row([
dbc.Tooltip("Display percentages positive and sampled"
" instead of absolute numbers",
target='liftcurve-percentage-'+self.name),
@@ -1003,7 +1004,7 @@ def layout(self):
]), hide=self.hide_percentage),
make_hideable(
html.Div([
dbc.FormGroup([
dbc.Row([
dbc.Tooltip("Display how a perfect model would perform"
"(the so-called 'wizard')",
target='liftcurve-wizard-'+self.name),
@@ -1017,7 +1018,7 @@ def layout(self):
]),
]), hide=self.hide_wizard),
]), hide=self.hide_footer)
])
], class_name="h-100")

def to_html(self, state_dict=None, add_header=True):
args = self.get_state_args(state_dict)
@@ -1159,7 +1160,7 @@ def layout(self):

])
]), hide=self.hide_footer)
])
], class_name="h-100")

def to_html(self, state_dict=None, add_header=True):
args = self.get_state_args(state_dict)
@@ -1288,7 +1289,7 @@ def layout(self):
], style={'margin-bottom': 25}), hide=self.hide_cutoff),
make_hideable(
html.Div([
dbc.FormGroup([
dbc.Row([
dbc.Tooltip("Do not resize the bar chart by absolute number of observations",
target='classification-percentage-'+self.name),
dbc.Checklist(
@@ -1301,7 +1302,7 @@ def layout(self):
]),
]), hide=self.hide_percentage),
]), hide=self.hide_footer)
])
], class_name="h-100")

def to_html(self, state_dict=None, add_header=True):
args = self.get_state_args(state_dict)
@@ -1412,7 +1413,7 @@ def layout(self):
placement='bottom'),
], style={'margin-bottom': 25}), hide=self.hide_cutoff),
]), hide=self.hide_footer)
])
], class_name="h-100")

def to_html(self, state_dict=None, add_header=True):
args = self.get_state_args(state_dict)
@@ -1523,7 +1524,7 @@ def layout(self):
placement='bottom'),
], style={'margin-bottom': 25}), hide=self.hide_cutoff),
]), hide=self.hide_footer)
])
], class_name="h-100")

def to_html(self, state_dict=None, add_header=True):
args = self.get_state_args(state_dict)
@@ -1624,7 +1625,7 @@ def layout(self):
placement='bottom'),
], style={'margin-bottom': 25}), hide=self.hide_cutoff),
]), hide=self.hide_footer)
])
], class_name="h-100")

def to_html(self, state_dict=None, add_header=True):
args = self.get_state_args(state_dict)
Loading