Exemple #1
0
 def layout(self):
     return html.Div([
         dbc.Row([
             make_hideable(dbc.Col([self.selector.layout()], width=3),
                           hide=self.hide_selector)
         ],
                 justify="end"),
         dcc.Graph(id='confusionmatrix-graph-' + self.name,
                   config=dict(modeBarButtons=[['toImage']],
                               displaylogo=False)),
         make_hideable(html.Div([
             html.Label('Cutoff prediction probability:'),
             dcc.Slider(id='confusionmatrix-cutoff-' + self.name,
                        min=0.01,
                        max=0.99,
                        step=0.01,
                        value=self.cutoff,
                        marks={
                            0.01: '0.01',
                            0.25: '0.25',
                            0.50: '0.50',
                            0.75: '0.75',
                            0.99: '0.99'
                        },
                        included=False,
                        tooltip={'always_visible': False})
         ],
                                style={'margin-bottom': 25}),
                       hide=self.hide_cutoff),
         make_hideable(html.Div([
             dbc.FormGroup([
                 dbc.RadioButton(
                     id='confusionmatrix-percentage-' + self.name,
                     className="form-check-input",
                     checked=self.percentage),
                 dbc.Label(
                     "Display percentages",
                     html_for="confusionmatrix-percentage-" + self.name,
                     className="form-check-label",
                 ),
             ],
                           check=True),
         ]),
                       hide=self.hide_percentage),
         make_hideable(html.Div([
             dbc.FormGroup([
                 dbc.RadioButton(id="confusionmatrix-binary-" + self.name,
                                 className="form-check-input",
                                 checked=self.binary),
                 dbc.Label(
                     "Binary (use cutoff for positive vs not positive)",
                     html_for="confusionmatrix-binary-" + self.name,
                     className="form-check-label",
                 ),
             ],
                           check=True),
         ]),
                       hide=self.hide_binary),
     ])
Exemple #2
0
 def layout(self):
     return html.Div([
         dbc.Row(
             [make_hideable(html.H3("Predictions"), hide=self.hide_title)]),
         dbc.Row([
             make_hideable(
                 dbc.Col(
                     [
                         dbc.FormGroup(
                             [
                                 # html.Label("Log y"),
                                 dbc.RadioButton(
                                     id='pred-vs-actual-logy-' + self.name,
                                     className="form-check-input",
                                     checked=self.log_y),
                                 dbc.Label("Log y",
                                           html_for='pred-vs-actual-logy-' +
                                           self.name,
                                           className="form-check-label"),
                             ],
                             check=True),
                     ],
                     md=1,
                     align="center"),
                 hide=self.hide_log_y),
             dbc.Col([
                 dcc.Graph(id='pred-vs-actual-graph-' + self.name,
                           config=dict(modeBarButtons=[['toImage']],
                                       displaylogo=False)),
             ],
                     md=11)
         ]),
         dbc.Row([
             make_hideable(dbc.Col([
                 dbc.FormGroup([
                     dbc.RadioButton(id='pred-vs-actual-logx-' + self.name,
                                     className="form-check-input",
                                     checked=self.log_x),
                     dbc.Label("Log x",
                               html_for='pred-vs-actual-logx-' + self.name,
                               className="form-check-label"),
                 ],
                               check=True),
             ],
                                   md=2),
                           hide=self.hide_log_x),
         ],
                 justify="center")
     ])
    def layout(self):
        cats_display = 'none' if self.explainer.cats is None else None
        return dbc.Container([
            dbc.Row([dbc.Col([html.H2('Feature Importances:')])]),
            dbc.Row([
                dbc.Col([
                    dbc.FormGroup(
                            [
                                dbc.Label("Importances type:"),
                                dbc.RadioItems(
                                    options=[
                                        {'label': 'Permutation Importances', 
                                        'value': 'permutation'},
                                        {'label': 'SHAP values', 
                                        'value': 'shap'}
                                    ],
                                    value='shap',
                                    id='permutation-or-shap',
                                    inline=True,
                                ),
                            ]
                        )
                ]),
                dbc.Col([
                    html.Label('Select max number of importances to display:'),
                    dcc.Dropdown(id='importance-tablesize',
                                        options = [{'label': str(i+1), 'value':i+1} 
                                                    for i in range(len(self.explainer.columns_cats))],
                                        value=min(self.n_features, len(self.explainer.columns_cats)))
                ]),
                dbc.Col([
                    html.Div([
                        dbc.Label("Grouping:"),
                        dbc.FormGroup(
                        [
                            dbc.RadioButton(
                                id='group-categoricals', 
                                className="form-check-input",
                                checked=True),
                            dbc.Label("Group Cats",
                                    html_for='group-categoricals',
                                    className="form-check-label"),
                        ], check=True),
                    ], style=cats_display)
                ]),
                    
            ], form=True, justify="between"),

            dbc.Row([
                dbc.Col([
                    dcc.Loading(id="loading-importances-graph", 
                            children=[dcc.Graph(id='importances-graph')])
                ]),
            ]), 
            ], fluid=True)
Exemple #4
0
 def layout(self):
     return dbc.Card([
         make_hideable(dbc.CardHeader([
             html.H3(self.title),
         ]),
                       hide=self.hide_title),
         dbc.CardBody([
             dbc.Row([
                 make_hideable(dbc.Col([
                     dbc.Label(f"{self.explainer.index_name}:"),
                     dcc.Dropdown(id='modelprediction-index-' + self.name,
                                  options=[{
                                      'label': str(idx),
                                      'value': idx
                                  } for idx in self.explainer.idxs],
                                  value=self.index)
                 ],
                                       md=6),
                               hide=self.hide_index),
                 make_hideable(dbc.Col([self.selector.layout()], width=3),
                               hide=self.hide_selector),
                 make_hideable(dbc.Col([
                     dbc.Label("Show Percentile:"),
                     dbc.FormGroup([
                         dbc.RadioButton(
                             id='modelprediction-percentile-' + self.name,
                             className="form-check-input",
                             checked=self.percentile),
                         dbc.Label("Show percentile",
                                   html_for='modelprediction-percentile' +
                                   self.name,
                                   className="form-check-label"),
                     ],
                                   check=True)
                 ],
                                       md=3),
                               hide=self.hide_percentile),
             ]),
             dbc.Row([
                 dbc.Col([
                     dcc.Markdown(id='modelprediction-' + self.name),
                 ],
                         md=12)
             ])
         ])
     ])
 def layout(self):
     return dbc.Container([
         dbc.Row([dbc.Col([html.H2('Model Performance:')])]),
         dbc.Row([
             dbc.Col([
                 html.Div([
                     dcc.Loading(id="loading-precision-graph",
                                 children=[dcc.Graph(id='precision-graph')
                                           ]),
                 ],
                          style={'margin': 0}),
                 html.Div([
                     dbc.Label('Bin size:', html_for='precision-binsize'),
                     html.Div([
                         dcc.Slider(id='precision-binsize',
                                    min=0.01,
                                    max=0.5,
                                    step=0.01,
                                    value=self.bin_size,
                                    marks={
                                        0.01: '0.01',
                                        0.05: '0.05',
                                        0.10: '0.10',
                                        0.20: '0.20',
                                        0.25: '0.25',
                                        0.33: '0.33',
                                        0.5: '0.5'
                                    },
                                    included=False,
                                    tooltip={'always_visible': False})
                     ],
                              style={'margin-bottom': 25}),
                 ],
                          id='bin-size-div',
                          style={'margin': 5}),
                 html.Div([
                     dbc.Label('Quantiles:',
                               html_for='precision-quantiles'),
                     html.Div([
                         dcc.Slider(id='precision-quantiles',
                                    min=1,
                                    max=20,
                                    step=1,
                                    value=self.quantiles,
                                    marks={
                                        1: '1',
                                        5: '5',
                                        10: '10',
                                        15: '15',
                                        20: '20'
                                    },
                                    included=False,
                                    tooltip={'always_visible': False}),
                     ],
                              style={'margin-bottom': 25}),
                 ],
                          id='quantiles-div',
                          style={'margin': 5}),
                 dbc.Label('Binning Method:',
                           html_for='binsize-or-quantiles'),
                 dbc.RadioItems(id='binsize-or-quantiles',
                                options=[{
                                    'label': 'Bin Size',
                                    'value': 'bin_size'
                                }, {
                                    'label': 'Quantiles',
                                    'value': 'quantiles'
                                }],
                                value='bin_size',
                                inline=True),
                 dbc.FormGroup([
                     dbc.RadioButton(id="precision-multiclass",
                                     className="form-check-input"),
                     dbc.Label(
                         "Display all classes",
                         html_for="precision-multiclass",
                         className="form-check-label",
                     ),
                 ],
                               check=True),
             ],
                     md=6,
                     align="start"),
             dbc.Col([
                 dcc.Loading(
                     id="loading-confusionmatrix-graph",
                     children=[dcc.Graph(id='confusionmatrix-graph')]),
                 dbc.FormGroup([
                     dbc.RadioButton(id='confusionmatrix-percentage',
                                     className="form-check-input",
                                     checked=True),
                     dbc.Label(
                         "Display percentages",
                         html_for="confusionmatrix-percentage",
                         className="form-check-label",
                     ),
                 ],
                               check=True),
                 dbc.FormGroup([
                     dbc.RadioButton(id="confusionmatrix-binary",
                                     className="form-check-input",
                                     checked=True),
                     dbc.Label(
                         "Binary (use cutoff for positive vs not positive)",
                         html_for="confusionmatrix-binary",
                         className="form-check-label",
                     ),
                 ],
                               check=True),
             ],
                     md=6,
                     align="start"),
         ]),
         dbc.Row([
             dbc.Col([
                 html.Div([
                     html.Label('Cutoff prediction probability:'),
                     dcc.Slider(id='precision-cutoff',
                                min=0.01,
                                max=0.99,
                                step=0.01,
                                value=self.cutoff,
                                marks={
                                    0.01: '0.01',
                                    0.25: '0.25',
                                    0.50: '0.50',
                                    0.75: '0.75',
                                    0.99: '0.99'
                                },
                                included=False,
                                tooltip={'always_visible': False})
                 ],
                          style={'margin-bottom': 25}),
             ])
         ]),
         dbc.Row([
             dbc.Col([
                 html.Div([
                     html.Label('Cutoff percentile of samples:'),
                     dcc.Slider(id='percentile-cutoff',
                                min=0.01,
                                max=0.99,
                                step=0.01,
                                value=self.cutoff,
                                marks={
                                    0.01: '0.01',
                                    0.25: '0.25',
                                    0.50: '0.50',
                                    0.75: '0.75',
                                    0.99: '0.99'
                                },
                                included=False,
                                tooltip={'always_visible': False})
                 ],
                          style={'margin-bottom': 25}),
             ])
         ]),
         dbc.Row([
             dbc.Col([
                 html.Div([
                     dcc.Loading(
                         id="loading-lift-curve",
                         children=[dcc.Graph(id='lift-curve-graph')]),
                 ],
                          style={'margin': 0}),
                 dbc.FormGroup([
                     dbc.RadioButton(id="lift-curve-percentage",
                                     className="form-check-input",
                                     checked=True),
                     dbc.Label(
                         "Display percentages",
                         html_for="lift-curve-percentage",
                         className="form-check-label",
                     ),
                 ],
                               check=True),
             ],
                     md=6,
                     align="start"),
             dbc.Col([
                 html.Div([
                     dcc.Loading(
                         id="loading-classification-graph",
                         children=[dcc.Graph(id='classification-graph')]),
                 ],
                          style={'margin': 0}),
                 dbc.FormGroup([
                     dbc.RadioButton(id="classification-percentage",
                                     className="form-check-input",
                                     checked=True),
                     dbc.Label(
                         "Display percentages",
                         html_for="classification-percentage",
                         className="form-check-label",
                     ),
                 ],
                               check=True),
             ],
                     md=6,
                     align="start"),
         ]),
         dbc.Row([
             dbc.Col([
                 dcc.Loading(id="loading-roc-auc-graph",
                             children=[dcc.Graph(id='roc-auc-graph')]),
             ],
                     md=6),
             dbc.Col([
                 dcc.Loading(id="loading-pr-auc-graph",
                             children=[dcc.Graph(id='pr-auc-graph')]),
             ],
                     md=6),
         ]),
     ],
                          fluid=True)
Exemple #6
0
         dbc.InputGroupAddon("Default", addon_type="prepend"),
         dbc.Input()
     ]),
     html.Br(),
     dbc.InputGroup(
         [
             dbc.InputGroupAddon("Small", addon_type="prepend"),
             dbc.Input()
         ],
         size="sm",
     ),
 ]),
 html.Br(),
 html.Div([
     dbc.InputGroup([
         dbc.InputGroupAddon(dbc.RadioButton(), addon_type='prepend'),
         dbc.Input(),
     ],
                    className='mb-3'),
     dbc.InputGroup([
         dbc.InputGroupAddon(dbc.Checkbox(), addon_type='prepend'),
         dbc.Input(),
     ])
 ]),
 html.Br(),
 dbc.InputGroup([
     dbc.InputGroupAddon(
         dbc.Button("Random name", id="input-group-button"),
         addon_type="prepend",
     ),
     dbc.Input(id="input-group-button-input", placeholder="name"),
Exemple #7
0
 def layout(self):
     return html.Div([
         html.H3(f"Select {self.explainer.index_name}:"),
         dbc.Row([
             make_hideable(
                 dbc.Col([
                         dcc.Dropdown(id='random-index-reg-index-'+self.name,
                                 options = [{'label': str(idx), 'value':idx}
                                                 for idx in self.explainer.idxs],
                                 value=self.index)
                     ], md=8), hide=self.hide_index),
             make_hideable(
                 dbc.Col([
                     dbc.Button(f"Random {self.explainer.index_name}", color="primary", id='random-index-reg-button-'+self.name, block=True)
                 ], md=4), hide=self.hide_button),
         ], form=True),
         make_hideable(
             html.Div([
             html.Div([
                 dbc.Row([
                         dbc.Col([
                             html.Div([
                                 dbc.Label("Predictions range:",
                                     html_for='random-index-reg-pred-slider-'+self.name),
                                 dcc.RangeSlider(
                                     id='random-index-reg-pred-slider-'+self.name,
                                     min=self.explainer.preds.min(),
                                     max=self.explainer.preds.max(),
                                     step=np.float_power(10, -self.round),
                                     value=[self.pred_slider[0], self.pred_slider[1]],
                                     marks={self.explainer.preds.min(): str(np.round(self.explainer.preds.min(), self.round)),
                                         self.explainer.preds.max(): str(np.round(self.explainer.preds.max(), self.round))},
                                     allowCross=False,
                                     tooltip = {'always_visible' : False}
                                 )
                             ], style={'margin-bottom':0})
                         ])
                 ]),
             ], id='random-index-reg-pred-slider-div-'+self.name),
             html.Div([
                 dbc.Row([
                         dbc.Col([
                             html.Div([
                                 dbc.Label("Y range:",
                                     html_for='random-index-reg-y-slider-'+self.name),
                                 dcc.RangeSlider(
                                     id='random-index-reg-y-slider-'+self.name,
                                     min=self.explainer.y.min(),
                                     max=self.explainer.y.max(),
                                     step=np.float_power(10, -self.round),
                                     value=[self.y_slider[0], self.y_slider[1]],
                                     marks={self.explainer.y.min(): str(np.round(self.explainer.y.min(), self.round)),
                                         self.explainer.y.max(): str(np.round(self.explainer.y.max(), self.round))},
                                     allowCross=False,
                                     tooltip = {'always_visible' : False}
                                 )
                             ], style={'margin-bottom':0})
                         ]),
                 ]),
             ], id='random-index-reg-y-slider-div-'+self.name),
             ]), hide=self.hide_pred_slider),
         make_hideable(
             html.Div([
             html.Div([
                 dbc.Row([
                     dbc.Col([
                         html.Div([
                             dbc.Label("Residuals range:",
                                 html_for='random-index-reg-residual-slider-'+self.name),
                             dcc.RangeSlider(
                                 id='random-index-reg-residual-slider-'+self.name,
                                 min=self.explainer.residuals.min(),
                                 max=self.explainer.residuals.max(),
                                 step=np.float_power(10, -self.round),
                                 value=[self.residual_slider[0], self.residual_slider[1]],
                                 marks={self.explainer.residuals.min(): str(np.round(self.explainer.residuals.min(), self.round)),
                                     self.explainer.residuals.max(): str(np.round(self.explainer.residuals.max(), self.round))},
                                 allowCross=False,
                                 tooltip={'always_visible' : False}
                             )
                         ], style={'margin-bottom':0})
                     ])
                 ]),
             ], id='random-index-reg-residual-slider-div-'+self.name),
             html.Div([
                 dbc.Row([
                     dbc.Col([
                         html.Div([
                             dbc.Label("Absolute residuals range:",
                                 html_for='random-index-reg-abs-residual-slider-'+self.name),
                             dcc.RangeSlider(
                                 id='random-index-reg-abs-residual-slider-'+self.name,
                                 min=self.explainer.abs_residuals.min(),
                                 max=self.explainer.abs_residuals.max(),
                                 step=np.float_power(10, -self.round),
                                 value=[self.abs_residual_slider[0], self.abs_residual_slider[1]],
                                 marks={self.explainer.abs_residuals.min(): str(np.round(self.explainer.abs_residuals.min(), self.round)),
                                     self.explainer.abs_residuals.max(): str(np.round(self.explainer.abs_residuals.max(), self.round))},
                                 allowCross=False,
                                 tooltip={'always_visible' : False}
                             )
                         ], style={'margin-bottom':0})
                     ])
                 ])
             ], id='random-index-reg-abs-residual-slider-div-'+self.name),
         ]), hide=self.hide_residual_slider),
         dbc.Row([
             make_hideable(
                 dbc.Col([
                     dbc.RadioItems(
                         id='random-index-reg-preds-or-y-'+self.name,
                         options=[
                             {'label': 'Use preds', 'value': 'preds'},
                             {'label': 'Use y', 'value': 'y'},
                         ],
                         value=self.pred_or_y,
                         inline=True)
                 ], md=4), hide=self.hide_pred_or_y),
             make_hideable(
                 dbc.Col([
                     dbc.FormGroup(
                     [
                         dbc.RadioButton(
                             id='random-index-reg-abs-residual-'+self.name,
                             className="form-check-input",
                             checked=self.abs_residuals),
                         dbc.Label("Absolute residuals range:",
                                 html_for='random-index-reg-abs-residual-'+self.name,
                                 className="form-check-label"),
                     ], check=True),
                 ]), hide=self.hide_abs_residuals),
         ]),
     ])
 def layout(self):
     return html.Div([
         dbc.Row([
             make_hideable(dbc.Col([html.H2('Feature Importances:')]),
                           hide=self.hide_title),
         ]),
         dbc.Row([
             make_hideable(
                 dbc.Col([
                     dbc.FormGroup([
                         dbc.Label("Importances type:"),
                         dbc.RadioItems(
                             options=[{
                                 'label': 'Permutation Importances',
                                 'value': 'permutation'
                             }, {
                                 'label': 'SHAP values',
                                 'value': 'shap'
                             }],
                             value=self.importance_type,
                             id='importances-permutation-or-shap-' +
                             self.name,
                             inline=True,
                         ),
                     ]),
                 ]), self.hide_type),
             make_hideable(
                 dbc.Col([
                     html.Label('Depth:'),
                     dcc.Dropdown(id='importances-depth-' + self.name,
                                  options=[{
                                      'label': str(i + 1),
                                      'value': i + 1
                                  } for i in range(
                                      self.explainer.n_features(self.cats))
                                           ],
                                  value=self.depth)
                 ],
                         md=3), self.hide_depth),
             make_hideable(
                 dbc.Col([
                     dbc.Label("Grouping:"),
                     dbc.FormGroup([
                         dbc.RadioButton(
                             id='importances-group-cats-' + self.name,
                             className="form-check-input",
                             checked=self.cats),
                         dbc.Label(
                             "Group Cats",
                             html_for='importances-group-cats-' + self.name,
                             className="form-check-label"),
                     ],
                                   check=True),
                 ]), self.hide_cats),
             make_hideable(dbc.Col([self.selector.layout()], width=2),
                           hide=self.hide_selector)
         ],
                 form=True),
         dbc.Row([
             dbc.Col([
                 dcc.Graph(id='importances-graph-' + self.name,
                           config=dict(modeBarButtons=[['toImage']],
                                       displaylogo=False))
             ]),
         ]),
     ])
 def layout(self):
     return html.Div([
         dbc.Row([
             make_hideable(html.Div([
                 html.H3(self.title, id='reg-vs-col-title-' + self.name),
                 dbc.Tooltip(self.description,
                             target='reg-vs-col-title-' + self.name),
             ]),
                           hide=self.hide_title),
         ]),
         dbc.Row([
             make_hideable(dbc.Col([
                 dbc.Label("Feature:",
                           id='reg-vs-col-col-label-' + self.name),
                 dbc.Tooltip("Select the feature to display on the x-axis.",
                             target='reg-vs-col-col-label-' + self.name),
                 dcc.Dropdown(id='reg-vs-col-col-' + self.name,
                              options=[{
                                  'label': col,
                                  'value': col
                              } for col in self.explainer.
                                       columns_ranked_by_shap(self.cats)],
                              value=self.col),
             ],
                                   md=4),
                           hide=self.hide_col),
             make_hideable(dbc.Col([
                 html.Label(
                     'Display:',
                     id='reg-vs-col-display-type-label-' + self.name),
                 dbc.Tooltip(
                     f"Select what to display on the y axis: observed {self.explainer.target}, "
                     f"predicted {self.explainer.target} or residuals. Residuals can either "
                     "be calculated by takind the difference (y-preds), "
                     "ratio (y/preds) or log ratio log(y/preds). The latter makes it easier to "
                     "see relative differences.",
                     target='reg-vs-col-display-type-label-' + self.name),
                 dcc.Dropdown(id='reg-vs-col-display-type-' + self.name,
                              options=[{
                                  'label': 'Observed',
                                  'value': 'observed'
                              }, {
                                  'label': 'Predicted',
                                  'value': 'predicted'
                              }, {
                                  'label': 'Residuals: Difference',
                                  'value': 'difference'
                              }, {
                                  'label': 'Residuals: Ratio',
                                  'value': 'ratio'
                              }, {
                                  'label': 'Residuals: Log ratio',
                                  'value': 'log-ratio'
                              }],
                              value=self.display),
             ],
                                   md=4),
                           hide=self.hide_ratio),
             make_hideable(
                 dbc.Col([
                     dbc.Label(
                         "Grouping:",
                         id='reg-vs-col-group-cats-label-' + self.name),
                     dbc.Tooltip(
                         "group onehot encoded features together.",
                         target='reg-vs-col-group-cats-label-' + self.name),
                     dbc.FormGroup([
                         dbc.RadioButton(
                             id='reg-vs-col-group-cats-' + self.name,
                             className="form-check-input",
                             checked=self.cats),
                         dbc.Label(
                             "Group Cats",
                             html_for='reg-vs-col-group-cats-' + self.name,
                             className="form-check-label"),
                     ],
                                   check=True),
                 ],
                         md=2), self.hide_cats),
         ]),
         dbc.Row([
             dcc.Graph(id='reg-vs-col-graph-' + self.name,
                       config=dict(modeBarButtons=[['toImage']],
                                   displaylogo=False)),
         ]),
         dbc.Row([
             make_hideable(dbc.Col([
                 dbc.Label("Winsor:",
                           id='reg-vs-col-winsor-label-' + self.name),
                 dbc.Tooltip(
                     "Excluded the highest and lowest y values from the plot. "
                     "When you have some real outliers it can help to remove them"
                     " from the plot so it is easier to see the overall pattern.",
                     target='reg-vs-col-winsor-label-' + self.name),
                 dbc.Input(id='reg-vs-col-winsor-' + self.name,
                           value=self.winsor,
                           type="number",
                           min=0,
                           max=49,
                           step=1),
             ],
                                   md=2),
                           hide=self.hide_winsor),
             make_hideable(
                 dbc.Col([
                     dbc.Label(
                         "Points:",
                         id='reg-vs-col-show-points-label-' + self.name),
                     dbc.Tooltip(
                         "For categorical features, display a point cloud next to the violin plot.",
                         target='reg-vs-col-show-points-label-' +
                         self.name),
                     dbc.FormGroup([
                         dbc.RadioButton(
                             id='reg-vs-col-show-points-' + self.name,
                             className="form-check-input",
                             checked=self.points),
                         dbc.Label(
                             "Show points",
                             html_for='reg-vs-col-show-points-' + self.name,
                             className="form-check-label"),
                     ],
                                   check=True),
                 ],
                         md=3), self.hide_points),
         ]),
     ])
Exemple #10
0
    html.Div([
        dbc.FormGroup(
            [
                dbc.Checkbox(id="standalone-checkbox",
                             className="form-check-input"),
                dbc.Label(
                    "This is a checkbox",
                    html_for="standalone-checkbox",
                    className="form-check-label",
                ),
            ],
            check=True,
        ),
        dbc.FormGroup(
            [
                dbc.RadioButton(id="standalone-radio",
                                className="form-check-input"),
                dbc.Label(
                    "This is a radio button",
                    html_for="standalone-radio",
                    className="form-check-label",
                ),
            ],
            check=True,
        ),
        html.Br(),
        html.P(id="standalone-radio-check-output"),
    ]),
],
                           className='mt-3')

 def layout(self):
     return html.Div([
             make_hideable(
             html.Div([
                 html.H3(self.title, id='pdp-title-'+self.name),
                 dbc.Tooltip(self.description, target='pdp-title-'+self.name),
             ]), hide=self.hide_title),
             dbc.Row([
                 make_hideable(
                     dbc.Col([
                         dbc.Label("Feature:", 
                                 html_for='pdp-col'+self.name, id='pdp-col-label-'+self.name),
                         dbc.Tooltip("Select the feature for which you want to see the partial dependence plot", 
                                     target='pdp-col-label-'+self.name),
                         dcc.Dropdown(id='pdp-col-'+self.name,       
                             options=[{'label': col, 'value':col} 
                                         for col in self.explainer.columns_ranked_by_shap(self.cats)],
                             value=self.col),
                     ], md=4), hide=self.hide_col),
                 make_hideable(
                     dbc.Col([
                         dbc.Label(f"{self.explainer.index_name}:", id='pdp-index-label-'+self.name),
                         dbc.Tooltip(f"Select the {self.explainer.index_name} to display the partial dependence plot for", 
                                 target='pdp-index-label-'+self.name),
                         dcc.Dropdown(id='pdp-index-'+self.name, 
                             options = [{'label': str(idx), 'value':idx} 
                                             for idx in self.explainer.idxs],
                             value=None)
                     ], md=4), hide=self.hide_index), 
                 make_hideable(
                     dbc.Col([self.selector.layout()
                 ], width=2), hide=self.hide_selector),
                 make_hideable(
                     dbc.Col([
                         dbc.Label("Grouping:", id='pdp-group-cats-label-'+self.name),
                         dbc.Tooltip("Group onehot encoded categorical variables together", 
                                     target='pdp-group-cats-label-'+self.name),
                         dbc.FormGroup(
                         [
                             dbc.RadioButton(
                                 id='pdp-group-cats-'+self.name, 
                                 className="form-check-input",
                                 checked=self.cats),
                             dbc.Label("Group Cats",
                                     html_for='pdp-group-cats-'+self.name, 
                                     className="form-check-label"),
                         ], check=True),
                     ], md=2), hide=self.hide_cats),
                 
             ], form=True),
             dbc.Row([
                 dbc.Col([
                     dcc.Loading(id='loading-pdp-graph-'+self.name, 
                         children=[dcc.Graph(id='pdp-graph-'+self.name,
                                             config=dict(modeBarButtons=[['toImage']], displaylogo=False))]),
                 ])
             ]),
             dbc.Row([
                 make_hideable(
                     dbc.Col([ #
                         dbc.Label("Drop na:",id='pdp-dropna-label-'+self.name ),
                         dbc.Tooltip(f"drop all observations with feature values equal to {self.explainer.na_fill}"
                                     " from the plot. This prevents the filler values from "
                                     "ruining the x-axis.", target='pdp-dropna-label-'+self.name ),
                         dbc.FormGroup(
                         [
                             dbc.RadioButton(
                                 id='pdp-dropna-'+self.name, 
                                 className="form-check-input",
                                 checked=self.dropna),
                             dbc.Label("Drop na's",
                                     html_for='pdp-dropna-'+self.name, 
                                     className="form-check-label"),
                         ], check=True),
                     ]), hide=self.hide_dropna),
                 make_hideable(
                     dbc.Col([ 
                         dbc.Label("pdp sample size", id='pdp-sample-label-'+self.name ),
                         dbc.Tooltip("Number of observations to use to calculate average partial dependence", 
                                     target='pdp-sample-label-'+self.name ),
                         dbc.Input(id='pdp-sample-'+self.name, value=self.sample,
                             type="number", min=0, max=len(self.explainer), step=1),
                     ]), hide=self.hide_sample),  
                 make_hideable(   
                     dbc.Col([ #gridlines
                         dbc.Label("gridlines", id='pdp-gridlines-label-'+self.name ),
                         dbc.Tooltip("Number of individual observations' partial dependences to show in plot", 
                                     target='pdp-gridlines-label-'+self.name),
                         dbc.Input(id='pdp-gridlines-'+self.name, value=self.gridlines,
                                 type="number", min=0, max=len(self.explainer), step=1),
                     ]), hide=self.hide_gridlines),
                 make_hideable(
                     dbc.Col([ #gridpoints
                         dbc.Label("gridpoints", id='pdp-gridpoints-label-'+self.name ),
                         dbc.Tooltip("Number of points to sample the feature axis for predictions."
                                     " The higher, the smoother the curve, but takes longer to calculate", 
                                     target='pdp-gridpoints-label-'+self.name ),
                         dbc.Input(id='pdp-gridpoints-'+self.name, value=self.gridpoints,
                             type="number", min=0, max=100, step=1),
                     ]), hide=self.hide_gridpoints),
             ], form=True)
     ])
    def layout(self):
        return html.Div([
            dbc.Row([
                make_hideable(
                    dbc.Col([html.H2('Feature Importances:')]), hide=self.hide_title),
            ]),
            dbc.Row([
                make_hideable(
                    dbc.Col([
                        dbc.FormGroup([
                            dbc.Label("Importances type:"),
                            dbc.RadioItems(
                                options=[
                                    {'label': 'Permutation Importances', 
                                    'value': 'permutation'},
                                    {'label': 'SHAP values', 
                                    'value': 'shap'}
                                ],
                                value=self.importance_type,
                                id='importances-permutation-or-shap-'+self.name,
                                inline=True,
                            ),
                            
                        ], id='importances-permutation-or-shap-form-'+self.name),
                        dbc.Tooltip("Select Feature importance type: \n"
                                "Permutation Importance: How much does performance metric decrease when shuffling this feature?\n"
                                "SHAP values: What is the average SHAP contribution (positive or negative) of this feature?",
                                target='importances-permutation-or-shap-form-'+self.name),
                    ]), self.hide_type),
                make_hideable(
                    dbc.Col([
                        html.Label('Depth:', id='importances-depth-label-'+self.name),
                        dcc.Dropdown(id='importances-depth-'+self.name,
                                            options = [{'label': str(i+1), 'value':i+1} 
                                                        for i in range(self.explainer.n_features(self.cats))],
                                            value=self.depth),
                        dbc.Tooltip("Select how many features to display", target='importances-depth-label-'+self.name)
                    ], md=3), self.hide_depth),
                make_hideable(
                    dbc.Col([
                        dbc.FormGroup(
                        [
                            dbc.Label("Grouping:", id='importances-group-cats-label-'+self.name),
                            dbc.Tooltip("Group onehot encoded categorical variables together", 
                                        target='importances-group-cats-label-'+self.name),
                            dbc.RadioButton(
                                id='importances-group-cats-'+self.name, 
                                className="form-check-input",
                                checked=self.cats),
                            dbc.Label("Group Cats",
                                    html_for='importances-group-cats-'+self.name,
                                    className="form-check-label"),
                        ], check=True, id='importances-group-cats-form-'+self.name), 
                    ]),  self.hide_cats),    
                make_hideable(
                        dbc.Col([self.selector.layout()
                    ], width=2), hide=self.hide_selector)    
            ], form=True),

            dbc.Row([
                dbc.Col([
                    dcc.Loading(id='importances-graph-loading-'+self.name,
                        children=dcc.Graph(id='importances-graph-'+self.name,
                                    config=dict(modeBarButtons=[['toImage']], displaylogo=False))),
                ]),
            ]), 
        ])
Exemple #13
0
 def layout(self):
     return html.Div([
         dbc.Row([make_hideable(html.H3(self.title),
                                hide=self.hide_title)]),
         dbc.Row([
             make_hideable(dbc.Col([
                 dbc.Label("Column:"),
                 dcc.Dropdown(id='preds-vs-col-col-' + self.name,
                              options=[{
                                  'label': col,
                                  'value': col
                              } for col in self.explainer.
                                       columns_ranked_by_shap(self.cats)],
                              value=self.col),
             ],
                                   md=4),
                           hide=self.hide_col),
             make_hideable(
                 dbc.Col([
                     dbc.Label("Grouping:"),
                     dbc.FormGroup([
                         dbc.RadioButton(
                             id='preds-vs-col-group-cats-' + self.name,
                             className="form-check-input",
                             checked=self.cats),
                         dbc.Label("Group Cats",
                                   html_for='preds-vs-col-group-cats-' +
                                   self.name,
                                   className="form-check-label"),
                     ],
                                   check=True),
                 ],
                         md=2), self.hide_cats),
         ]),
         dbc.Row([
             dcc.Graph(id='preds-vs-col-graph-' + self.name,
                       config=dict(modeBarButtons=[['toImage']],
                                   displaylogo=False)),
         ]),
         dbc.Row([
             make_hideable(dbc.Col([
                 dbc.Label("Winsor:"),
                 dbc.Input(id='preds-vs-col-winsor-' + self.name,
                           value=self.winsor,
                           type="number",
                           min=0,
                           max=49,
                           step=1),
             ],
                                   md=2),
                           hide=self.hide_winsor),
             make_hideable(
                 dbc.Col([
                     dbc.Label("Points:"),
                     dbc.FormGroup([
                         dbc.RadioButton(
                             id='preds-vs-col-show-points-' + self.name,
                             className="form-check-input",
                             checked=self.points),
                         dbc.Label("Show points",
                                   html_for='preds-vs-col-show-points-' +
                                   self.name,
                                   className="form-check-label"),
                     ],
                                   check=True),
                 ],
                         md=3), self.hide_points),
         ]),
     ])
import dash_bootstrap_components as dbc
import dash_html_components as html

input_groups = html.Div([
    dbc.InputGroup(
        [
            dbc.InputGroupAddon(dbc.RadioButton(), addon_type="prepend"),
            dbc.Input(),
        ],
        className="mb-3",
    ),
    dbc.InputGroup([
        dbc.InputGroupAddon(dbc.Checkbox(), addon_type="prepend"),
        dbc.Input(),
    ]),
])
    def layout(self):
        return dbc.Container([
            dbc.Row([dbc.Col([html.H2('Model Performance:')])]),
            dbc.Row([
                dbc.Col([

                    dcc.Loading(id="loading-predicted-vs-actual-graph",
                                children=[dcc.Graph(id='predicted-vs-actual-graph')]),
                    dbc.FormGroup(
                    [
                        dbc.RadioButton(
                            id='preds-vs-actual-logs',
                            className="form-check-input"),
                        dbc.Label("Take Logs",
                                html_for='preds-vs-actual-logs',
                                className="form-check-label"),
                    ], check=True),
                    ], width=6),
                dbc.Col([
                    dcc.Loading(id="loading-model-summary",
                                children=[dcc.Markdown(id='model-summary')]),
                ], width=6),
            ], align="start"),
            dbc.Row([
                dbc.Col([

                    dcc.Loading(id="loading-residuals-graph",
                                children=[dcc.Graph(id='residuals-graph')]),
                    dbc.FormGroup(
                    [
                        dbc.RadioItems(
                            options=[
                                {"label": "vs Prediction", "value": "vs_pred"},
                                {"label": "vs Actual", "value": "vs_actual"},
                            ],
                            value="vs_pred",
                            id='residuals-pred-or-actual',
                            inline=True,
                        ),
                    ]),
                    dbc.FormGroup(
                    [
                        dbc.RadioButton(
                            id='residuals-ratio',
                            className="form-check-input"),
                        dbc.Label("Display Ratio",
                                html_for='residuals-ratio',
                                className="form-check-label"),
                    ], check=True),

                ], width=6),
                dbc.Col([
                    dcc.Loading(id="loading-residuals-vs-col-graph",
                                children=[dcc.Graph(id='residuals-vs-col-graph')]),
                    dbc.Label("Column:"),
                    dcc.Dropdown(id='residuals-col',
                        options = [{'label': col, 'value': col}
                                        for col in self.explainer.mean_abs_shap_df(cats=False)\
                                                        .Feature.tolist()],
                        value=self.explainer.mean_abs_shap_df(cats=False)\
                                                        .Feature.tolist()[0]),
                    dbc.FormGroup(
                    [
                        dbc.RadioButton(
                            id='residuals-vs-col-ratio',
                            className="form-check-input"),
                        dbc.Label("Display Ratio",
                                html_for='residuals-vs-col-ratio',
                                className="form-check-label"),
                    ], check=True),
                ], width=6),
            ])
        ], fluid=True)
 def layout(self):
     return html.Div([
         dbc.Row([
             make_hideable(html.Div([
                 html.H3(self.title,
                         id='pred-vs-actual-title-' + self.name),
                 dbc.Tooltip(self.description,
                             target='pred-vs-actual-title-' + self.name),
             ]),
                           hide=self.hide_title),
         ]),
         dbc.Row([
             make_hideable(
                 dbc.Col(
                     [
                         dbc.FormGroup(
                             [
                                 # html.Label("Log y"),
                                 dbc.RadioButton(
                                     id='pred-vs-actual-logy-' + self.name,
                                     className="form-check-input",
                                     checked=self.log_y),
                                 dbc.Tooltip(
                                     "By using a log axis, it is easier to see relative "
                                     "errors instead of absolute errors.",
                                     target='pred-vs-actual-logy-' +
                                     self.name),
                                 dbc.Label("Log y",
                                           html_for='pred-vs-actual-logy-' +
                                           self.name,
                                           className="form-check-label"),
                             ],
                             check=True),
                     ],
                     md=1,
                     align="center"),
                 hide=self.hide_log_y),
             dbc.Col([
                 dcc.Graph(id='pred-vs-actual-graph-' + self.name,
                           config=dict(modeBarButtons=[['toImage']],
                                       displaylogo=False)),
             ],
                     md=11)
         ]),
         dbc.Row([
             make_hideable(dbc.Col([
                 dbc.FormGroup([
                     dbc.RadioButton(id='pred-vs-actual-logx-' + self.name,
                                     className="form-check-input",
                                     checked=self.log_x),
                     dbc.Tooltip(
                         "By using a log axis, it is easier to see relative "
                         "errors instead of absolute errors.",
                         target='pred-vs-actual-logx-' + self.name),
                     dbc.Label("Log x",
                               html_for='pred-vs-actual-logx-' + self.name,
                               className="form-check-label"),
                 ],
                               check=True),
             ],
                                   md=2),
                           hide=self.hide_log_x),
         ],
                 justify="center")
     ])
Exemple #17
0
def shap_dependence_layout(explainer, n_features=10, cats=True, **kwargs):

    cats_display = 'none' if explainer.cats is None else 'inline-block'
    return dbc.Container([
    dbc.Row([
        dbc.Col([
            html.H3('Shap Summary'),
            dbc.Row([
                dbc.Col([
                    dbc.Label("Depth:"),
                    dcc.Dropdown(id='dependence-scatter-depth',
                        options = [{'label': str(i+1), 'value':i+1} 
                                        for i in range(len(explainer.columns_ranked_by_shap(cats)) - 1)],
                        value=min(n_features, len(explainer.columns_ranked_by_shap(cats))-1))],
                    width=3), 
                dbc.Col([
                    dbc.FormGroup(
                        [
                            dbc.Label("Summary Type"),
                            dbc.RadioItems(
                                options=[
                                    {"label": "Aggregate", "value": "aggregate"},
                                    {"label": "Detailed", "value": "detailed"},
                                ],
                                value="aggregate",
                                id="dependence-summary-type",
                                inline=True,
                            ),
                        ]
                    )
                ], width=3),
                dbc.Col([
                    dbc.Label("Grouping:"),
                    dbc.FormGroup(
                    [
                        dbc.RadioButton(
                            id='dependence-group-categoricals', 
                            className="form-check-input",
                            checked=True),
                        dbc.Label("Group Cats",
                                html_for='dependence-group-categoricals',
                                className="form-check-label"),
                    ], check=True)],
                    width=3),
                ], form=True, justify="between"),

            dbc.Label('(Click on a dot to display dependece graph)'),
            dcc.Loading(id="loading-dependence-shap-summary", 
                    children=[dcc.Graph(id='dependence-shap-summary-graph')])
        ], width=6),
        dbc.Col([
            html.H3('Shap Dependence Plot'),
            dbc.Row([
                dbc.Col([
                    html.Label('Plot dependence for column:'),
                    dcc.Dropdown(id='dependence-col', 
                        options=[{'label': col, 'value':col} 
                                    for col in explainer.columns_ranked_by_shap(cats)],
                        value=explainer.columns_ranked_by_shap(cats)[0])],
                    width=5), 
                dbc.Col([
                     html.Label('Color observation by column:'),
                    dcc.Dropdown(id='dependence-color-col', 
                        options=[{'label': col, 'value':col} 
                                    for col in explainer.columns_ranked_by_shap(cats)],
                        value=explainer.columns_ranked_by_shap(cats)[1])],
                    width=5), 
                dbc.Col([
                    html.Label('Highlight:'),
                    dbc.Input(id='dependence-highlight-index', 
                            placeholder="Highlight index...",
                            debounce=True)]
                    , width=2) 
                ], form=True),
            
            dcc.Loading(id="loading-dependence-graph", 
                         children=[dcc.Graph(id='dependence-graph')]),
        ], width=6),
        ]),
    ],  fluid=True)
 [
     dbc.Col(
         [
             dbc.InputGroup(
                 [
                     dbc.InputGroupAddon(dbc.Button(
                         'Apartment',
                         style={
                             'padding-left': 30,
                             'padding-right': 30,
                             'color': '#93C54B'
                         },
                         className='btn-dark'),
                                         addon_type="prepend"),
                     dbc.InputGroupAddon(
                         dbc.RadioButton(id='apt-selected'),
                         addon_type='append')
                 ],
                 size="lg",
                 #style = {'width': '-webkit-fill-available'}
             ),
         ],
         width="auto"),
     dbc.Col([
         dbc.InputGroup([
             dbc.InputGroupAddon(dbc.Button('Condominium',
                                            style={
                                                'padding-left': 30,
                                                'padding-right': 30,
                                                'color': '#93C54B'
                                            },
 def layout(self):
     return html.Div([
         make_hideable(html.H3('Partial Dependence Plot:'),
                       hide=self.hide_title),
         dbc.Row([
             make_hideable(dbc.Col([
                 dbc.Label("Feature:", html_for='pdp-col'),
                 dcc.Dropdown(id='pdp-col-' + self.name,
                              options=[{
                                  'label': col,
                                  'value': col
                              } for col in self.explainer.
                                       columns_ranked_by_shap(self.cats)],
                              value=self.col),
             ],
                                   md=4),
                           hide=self.hide_col),
             make_hideable(dbc.Col([
                 dbc.Label(f"{self.explainer.index_name}:"),
                 dcc.Dropdown(id='pdp-index-' + self.name,
                              options=[{
                                  'label': str(idx),
                                  'value': idx
                              } for idx in self.explainer.idxs],
                              value=None)
             ],
                                   md=4),
                           hide=self.hide_index),
             make_hideable(dbc.Col([self.selector.layout()], width=2),
                           hide=self.hide_selector),
             make_hideable(dbc.Col([
                 dbc.Label("Grouping:"),
                 dbc.FormGroup([
                     dbc.RadioButton(id='pdp-group-cats-' + self.name,
                                     className="form-check-input",
                                     checked=self.cats),
                     dbc.Label("Group Cats",
                               html_for='pdp-group-cats-' + self.name,
                               className="form-check-label"),
                 ],
                               check=True)
             ],
                                   md=2),
                           hide=self.hide_cats),
         ],
                 form=True),
         dbc.Row([
             dbc.Col([
                 dcc.Loading(id='loading-pdp-graph-' + self.name,
                             children=[
                                 dcc.Graph(id='pdp-graph-' + self.name,
                                           config=dict(
                                               modeBarButtons=[['toImage']],
                                               displaylogo=False))
                             ]),
             ])
         ]),
         dbc.Row(
             [
                 make_hideable(
                     dbc.Col([  #
                         dbc.Label("Drop na:"),
                         dbc.FormGroup([
                             dbc.RadioButton(id='pdp-dropna-' + self.name,
                                             className="form-check-input",
                                             checked=self.dropna),
                             dbc.Label("Drop na's",
                                       html_for='pdp-dropna-' + self.name,
                                       className="form-check-label"),
                         ],
                                       check=True)
                     ]),
                     hide=self.hide_dropna),
                 make_hideable(dbc.Col([
                     dbc.Label("pdp sample size"),
                     dbc.Input(id='pdp-sample-' + self.name,
                               value=self.sample,
                               type="number",
                               min=0,
                               max=len(self.explainer),
                               step=1),
                 ]),
                               hide=self.hide_sample),
                 make_hideable(
                     dbc.Col([  #gridlines
                         dbc.Label("gridlines"),
                         dbc.Input(id='pdp-gridlines-' + self.name,
                                   value=self.gridlines,
                                   type="number",
                                   min=0,
                                   max=len(self.explainer),
                                   step=1),
                     ]),
                     hide=self.hide_gridlines),
                 make_hideable(
                     dbc.Col([  #gridpoints
                         dbc.Label("gridpoints"),
                         dbc.Input(id='pdp-gridpoints-' + self.name,
                                   value=self.gridpoints,
                                   type="number",
                                   min=0,
                                   max=100,
                                   step=1),
                     ]),
                     hide=self.hide_gridpoints),
             ],
             form=True)
     ])
def shap_interactions_layout(explainer, n_features=10, cats=True, **kwargs):
    """return layout for shap interactions tab.
    
    :param explainer: ExplainerBunch
    :type explainer: ExplainerBunch 
    :param title: title displayed on top of page, defaults to None
    :type title: str
    :param standalone: when standalone layout, include a a label_store, defaults to False
    :type standalone: bool
    :param hide_selector: if model is a classifier, optionally hide the positive label selector, defaults to False
    :type hide_selector: bool
    :param n_features: default number of features to display, defaults to 10
    :type n_features: int, optional
    :rtype: dbc.Container
    """
    cats_display = 'none' if explainer.cats is None else 'inline-block'
    return dbc.Container(
        [
            #dbc.Row([dbc.Col([html.H3('Shap Interaction Values')])]),
            dbc.Row([
                dbc.Col([
                    html.H3('Shap Interaction Summary'),
                    dbc.Row([
                        dbc.Col([
                            dbc.Label("Feature"),
                            dcc.Dropdown(
                                id='interaction-col',
                                options=[{
                                    'label': col,
                                    'value': col
                                } for col in explainer.columns_ranked_by_shap(
                                    cats)],
                                value=explainer.columns_ranked_by_shap(
                                    cats)[0])
                        ],
                                md=4),
                        dbc.Col([
                            dbc.Label("Depth:"),
                            dcc.Dropdown(
                                id='interaction-summary-depth',
                                options=[{
                                    'label':
                                    str(i + 1),
                                    'value':
                                    i + 1
                                } for i in range(
                                    len(explainer.columns_ranked_by_shap(cats))
                                    - 1)],
                                value=min(
                                    n_features,
                                    len(explainer.columns_ranked_by_shap(cats))
                                    - 1))
                        ],
                                md=2),
                        dbc.Col([
                            dbc.FormGroup([
                                dbc.Label("Summary Type"),
                                dbc.RadioItems(
                                    options=[
                                        {
                                            "label": "Aggregate",
                                            "value": "aggregate"
                                        },
                                        {
                                            "label": "Detailed",
                                            "value": "detailed"
                                        },
                                    ],
                                    value="aggregate",
                                    id="interaction-summary-type",
                                    inline=True,
                                ),
                            ])
                        ],
                                md=3),
                        dbc.Col([
                            dbc.Label("Grouping:"),
                            dbc.FormGroup([
                                dbc.RadioButton(
                                    id='interaction-group-categoricals',
                                    className="form-check-input",
                                    checked=cats),
                                dbc.Label(
                                    "Group Cats",
                                    html_for='interaction-group-categoricals',
                                    className="form-check-label"),
                            ],
                                          check=True)
                        ],
                                md=3),
                    ],
                            form=True),
                    dbc.Label('(Click on a dot to display interaction graph)'),
                    dcc.Loading(
                        id="loading-interaction-summary-scatter",
                        children=[
                            dcc.Graph(id='interaction-shap-summary-graph')
                        ])
                ],
                        md=6),
                dbc.Col([
                    html.H3('Shap Interaction Plots'),
                    dbc.Row([
                        dbc.Col([
                            dbc.Label("Interaction Feature"),
                            dcc.Dropdown(
                                id='interaction-interact-col',
                                options=[{
                                    'label':
                                    col,
                                    'value':
                                    col
                                } for col in explainer.columns_ranked_by_shap(
                                    cats)],
                                value=explainer.shap_top_interactions(
                                    explainer.columns_ranked_by_shap(cats)[0],
                                    cats=cats)[1]),
                        ],
                                md=8),
                        dbc.Col([
                            dbc.Label("Highlight index:"),
                            dbc.Input(id='interaction-highlight-index',
                                      placeholder="Highlight index...",
                                      debounce=True)
                        ],
                                md=4),
                    ],
                            form=True),
                    dcc.Loading(id="loading-interaction-graph",
                                children=[dcc.Graph(id='interaction-graph')]),
                    dcc.Loading(
                        id="loading-reverse-interaction-graph",
                        children=[dcc.Graph(id='reverse-interaction-graph')]),
                ],
                        md=6)
            ]),
        ],
        fluid=True)
Exemple #21
0
 def layout(self):
     return html.Div([
         dbc.Row([
             make_hideable(dbc.Col([self.selector.layout()], width=3),
                           hide=self.hide_selector)
         ],
                 justify="end"),
         dbc.Row([
             dbc.Col([
                 html.Div([
                     dcc.Graph(id='precision-graph-' + self.name,
                               config=dict(modeBarButtons=[['toImage']],
                                           displaylogo=False)),
                 ],
                          style={'margin': 0}),
             ])
         ]),
         dbc.Row([
             dbc.Col([
                 make_hideable(html.Div([
                     dbc.Label('Bin size:',
                               html_for='precision-binsize-' + self.name),
                     html.Div([
                         dcc.Slider(id='precision-binsize-' + self.name,
                                    min=0.01,
                                    max=0.5,
                                    step=0.01,
                                    value=self.bin_size,
                                    marks={
                                        0.01: '0.01',
                                        0.05: '0.05',
                                        0.10: '0.10',
                                        0.20: '0.20',
                                        0.25: '0.25',
                                        0.33: '0.33',
                                        0.5: '0.5'
                                    },
                                    included=False,
                                    tooltip={'always_visible': False})
                     ],
                              style={'margin-bottom': 5}),
                 ],
                                        id='precision-bin-size-div-' +
                                        self.name,
                                        style=dict(margin=5)),
                               hide=self.hide_binsize),
                 make_hideable(html.Div([
                     dbc.Label('Quantiles:',
                               html_for='precision-quantiles-' + self.name),
                     html.Div([
                         dcc.Slider(id='precision-quantiles-' + self.name,
                                    min=1,
                                    max=20,
                                    step=1,
                                    value=self.quantiles,
                                    marks={
                                        1: '1',
                                        5: '5',
                                        10: '10',
                                        15: '15',
                                        20: '20'
                                    },
                                    included=False,
                                    tooltip={'always_visible': False}),
                     ],
                              style={'margin-bottom': 5}),
                 ],
                                        id='precision-quantiles-div-' +
                                        self.name),
                               hide=self.hide_binsize),
                 make_hideable(html.Div([
                     html.Label('Cutoff prediction probability:'),
                     dcc.Slider(id='precision-cutoff-' + self.name,
                                min=0.01,
                                max=0.99,
                                step=0.01,
                                value=self.cutoff,
                                marks={
                                    0.01: '0.01',
                                    0.25: '0.25',
                                    0.50: '0.50',
                                    0.75: '0.75',
                                    0.99: '0.99'
                                },
                                included=False,
                                tooltip={'always_visible': False})
                 ],
                                        style={'margin-bottom': 5}),
                               hide=self.hide_cutoff),
             ]),
         ]),
         dbc.Row([
             make_hideable(dbc.Col([
                 dbc.Label('Binning Method:',
                           html_for='precision-binsize-or-quantiles-' +
                           self.name),
                 dbc.RadioItems(
                     id='precision-binsize-or-quantiles-' + self.name,
                     options=[{
                         'label': 'Bin Size',
                         'value': 'bin_size'
                     }, {
                         'label': 'Quantiles',
                         'value': 'quantiles'
                     }],
                     value=self.quantiles_or_binsize,
                     inline=True),
             ],
                                   width=3),
                           hide=self.hide_binmethod),
             make_hideable(dbc.Col([
                 dbc.FormGroup([
                     dbc.RadioButton(id="precision-multiclass-" + self.name,
                                     className="form-check-input",
                                     checked=self.multiclass),
                     dbc.Label(
                         "Display all classes",
                         html_for="precision-multiclass-" + self.name,
                         className="form-check-label",
                     ),
                 ],
                               check=True),
             ],
                                   width=3),
                           hide=self.hide_multiclass),
         ])
     ])
standalone_radio_check = html.Div([
    html.Div([
        dbc.Checkbox(
            id="standalone-checkbox",
            label="This is a checkbox",
            value=False,
        ),
        dbc.Switch(
            id="standalone-switch",
            label="This is a toggle switch",
            value=False,
        ),
        dbc.RadioButton(
            id="standalone-radio",
            label="This is a radio button",
            value=False,
        ),
    ]),
    html.P(id="standalone-radio-check-output"),
])


@app.callback(
    Output("standalone-radio-check-output", "children"),
    [
        Input("standalone-checkbox", "value"),
        Input("standalone-switch", "value"),
        Input("standalone-radio", "value"),
    ],
)