@@ -224,11 +224,10 @@ def dash(self, df, mode):
224224 dbc .Col (dbc .NavItem (dbc .NavLink ("Distributions" , href = "/apps/distribution" )),
225225 style = {'width' : "150px" , 'fontSize' : '10px' }),
226226 dbc .Col (dbc .NavItem (dbc .NavLink ("Cohort Analysis" , href = "/apps/cohort" )),
227- style = {'width' : "150px" , 'fontSize' : '10px' })
227+ style = {'width' : "150px" , 'fontSize' : '10px' })
228228
229229 ],
230230
231-
232231 no_gutters = True ,
233232 className = "ml-auto flex-nowrap mt-3 mt-md-0" ,
234233 align = "center"
@@ -284,43 +283,49 @@ def display_page(pathname):
284283 else :
285284 return welcome_message
286285
287-
288286 welcome_message = html .Div (
289287 [
290288 html .Div ([
291289 html .H3 ("Welcome to ExplainX.ai Explainable AI Dashboard" ),
292290 html .H4 ("Start explaining your model by exploring one of the following options." )
293- ], style = {'margin-left' :"20px" }),
291+ ], style = {'margin-left' : "20px" }),
294292 html .Div ([
295293 html .Div ([
296- html .Img (src = 'https://lh3.googleusercontent.com/uNkpoLQRIza6SSDk9fQed6bu6c1Q9zDkDjZqkRtF3cU97Smf2rS0soKo2ZQm32gJe8FyLYvNRUYJ-hqM7zs4esIAFchdPmgC4sHgbpxTKkGjm4dRK-NagI56K8vnXg8FH4s_Jct2RaQ' , className = "global_explanation_image" ),
294+ html .Img (
295+ src = 'https://lh3.googleusercontent.com/uNkpoLQRIza6SSDk9fQed6bu6c1Q9zDkDjZqkRtF3cU97Smf2rS0soKo2ZQm32gJe8FyLYvNRUYJ-hqM7zs4esIAFchdPmgC4sHgbpxTKkGjm4dRK-NagI56K8vnXg8FH4s_Jct2RaQ' ,
296+ className = "global_explanation_image" ),
297297
298298 dcc .Link ("Global Explanation" , href = "/apps/global_explanation" , className = "link" )
299- ], className = "welcome_box" , id = "global_explanation_deets" ),
300-
299+ ], className = "welcome_box" , id = "global_explanation_deets" ),
301300
302301 html .Div ([
303- html .Img (src = 'https://lh3.googleusercontent.com/LpM-N2QavBVxlMW6vKm5fmT5Qe3mYtI2q2OQc5kgZfW4kKOFlyidgrwT5C9zB3XHZncHvlGcFl82Si7bMDQN_PtLf4PThqdEUs1UwoUPeNHs0VYY6ICKlHi44ppZLZIMQvaWI4bMqm0' , className = "global_explanation_image" ),
302+ html .Img (
303+ src = 'https://lh3.googleusercontent.com/LpM-N2QavBVxlMW6vKm5fmT5Qe3mYtI2q2OQc5kgZfW4kKOFlyidgrwT5C9zB3XHZncHvlGcFl82Si7bMDQN_PtLf4PThqdEUs1UwoUPeNHs0VYY6ICKlHi44ppZLZIMQvaWI4bMqm0' ,
304+ className = "global_explanation_image" ),
304305
305306 dcc .Link ("Local Level Explanation" , href = "/apps/local_explanation" , className = "link" )
306307
307308 ], className = "welcome_box" , id = "local_explanation_deets" ),
308309
309310 html .Div ([
310- html .Img (src = 'https://lh6.googleusercontent.com/GXnNtGlqQcsRXugwwlZ31SwrJda4Z1WVyIi5i13vZImrUY6YgIZvM81d7zrBOh8n2jK_Lqj3BB5IqS4dU5l680-rZuu40bMXa-EAd8ag3WDIU2SNYieg0DH3e_FwUq5f2-y-X_POE-k' , className = "global_explanation_image" ),
311+ html .Img (
312+ src = 'https://lh6.googleusercontent.com/GXnNtGlqQcsRXugwwlZ31SwrJda4Z1WVyIi5i13vZImrUY6YgIZvM81d7zrBOh8n2jK_Lqj3BB5IqS4dU5l680-rZuu40bMXa-EAd8ag3WDIU2SNYieg0DH3e_FwUq5f2-y-X_POE-k' ,
313+ className = "global_explanation_image" ),
311314
312- dcc .Link ("Feature Interactions" , href = "/apps/feature_interaction" , className = "link" )
315+ dcc .Link ("Feature Interactions" , href = "/apps/feature_interaction" , className = "link" )
313316
314317 ], className = "welcome_box" , id = "feature_interaction_deets" ),
315318
316319 html .Div ([
317- html .Img (src = 'https://uploads-ssl.webflow.com/5edc18e72f7ba21e1ed2efae/5f519fd99580494301e67b7b_pipeline.png' , className = "global_explanation_image" ),
320+ html .Img (
321+ src = 'https://uploads-ssl.webflow.com/5edc18e72f7ba21e1ed2efae/5f519fd99580494301e67b7b_pipeline.png' ,
322+ className = "global_explanation_image" ),
318323
319324 dcc .Link ("Cohort Analysis" , href = "/apps/cohort" , className = "link" )
320325
321326 ], className = "welcome_box" , id = "cohort_analysis_deets" )
322327 ], className = "main_welcome_div" ),
323-
328+
324329 ]
325330
326331 )
@@ -335,8 +340,8 @@ def display_page(pathname):
335340 "Analyze using SQL" ,
336341 id = "collapse-button-2" ,
337342 color = "link" ,
338- style = {'fontSize' : '10px' , 'margin-top' :'0px' }), style = {"margin-top" :"0px" }),
339- style = {"height" :"50px" }),
343+ style = {'fontSize' : '10px' , 'margin-top' : '0px' }), style = {"margin-top" : "0px" }),
344+ style = {"height" : "50px" }),
340345 dbc .Collapse (html .Div ([
341346 html .Div (dcc .Input (
342347 id = 'input-on-submit' ,
@@ -366,8 +371,8 @@ def display_page(pathname):
366371 "View Your Data" ,
367372 id = "collapse-button" ,
368373 color = "link" ,
369- style = {'fontSize' : '10px' }), style = {"margin-top" :"0px" }),
370- style = {"height" :"50px" }),
374+ style = {'fontSize' : '10px' }), style = {"margin-top" : "0px" }),
375+ style = {"height" : "50px" }),
371376 dbc .Collapse (html .Div ([
372377 html .H4 ('' ,
373378 style = style1 ),
@@ -463,42 +468,39 @@ def toggle_collapse(n, is_open):
463468 return not is_open
464469 return is_open
465470
466- #Cohort Analysis - Callbacks
471+ # Cohort Analysis - Callbacks
467472 @app .callback (
468- Output ("modal" , "is_open" ),
469- [Input ("open" , "n_clicks" ), Input ("close" , "n_clicks" )],
470- [State ("modal" , "is_open" )],
471- prevent_initial_call = True )
473+ Output ("modal" , "is_open" ),
474+ [Input ("open" , "n_clicks" ), Input ("close" , "n_clicks" )],
475+ [State ("modal" , "is_open" )],
476+ prevent_initial_call = True )
472477 def toggle_modal (n1 , n2 , is_open ):
473478 if n1 or n2 :
474479 return not is_open
475480 return is_open
476481
477482 @app .callback (
478- [Output ("cohort-metrics-div" , "children" ),
479- Output ("cohort-details" , "children" ),
480- Output ("cohort-graph" , "children" )],
481- [Input ("add-cohort" ,"n_clicks" ),
482- Input ("remove-cohort" ,"n_clicks" ),
483- Input ("x-axis" ,"value" )],
484- [State ("demo-dropdown" ,"value" ),
485- State ("demo-operators" , "value" ),
486- State ("demo-values" , "value" )])
483+ [Output ("cohort-metrics-div" , "children" ),
484+ Output ("cohort-details" , "children" ),
485+ Output ("cohort-graph" , "children" )],
486+ [Input ("add-cohort" , "n_clicks" ),
487+ Input ("remove-cohort" , "n_clicks" ),
488+ Input ("x-axis" , "value" )],
489+ [State ("demo-dropdown" , "value" ),
490+ State ("demo-operators" , "value" ),
491+ State ("demo-values" , "value" )])
487492 def cohort_metrics_details (add_cohort , remove_cohort , x_axis , var_name , operator , value ):
488493 changed_id = [p ['prop_id' ] for p in dash .callback_context .triggered ][0 ]
489494 if 'remove-cohort' in changed_id :
490495 ca .remove_cohort ()
491496 fig = ca .cohort_graph (x_axis )
492- return ca .cohort_metrics_details (), ca .cohort_details (), dcc .Graph (figure = fig ),
497+ return ca .cohort_metrics_details (), ca .cohort_details (), dcc .Graph (figure = fig ),
493498 else :
494- ca .add_cohort_metrics (df , var_name , operator ,value , self .param ["is_classification" ])
499+ ca .add_cohort_metrics (df , var_name , operator , value , self .param ["is_classification" ])
495500 cohort = ca .add_cohort (df , x_axis , var_name , operator , value )
496501 fig = ca .cohort_graph (x_axis )
497502 return ca .cohort_metrics_details (), ca .cohort_details (), dcc .Graph (figure = fig )
498503
499-
500-
501-
502504 # SQL - Data Input Callback
503505 @app .callback (
504506 dash .dependencies .Output ('sql-query-button' , 'children' ),
@@ -507,7 +509,6 @@ def cohort_metrics_details(add_cohort, remove_cohort, x_axis, var_name, operator
507509 def update_output (n_clicks , value ):
508510 sql_query = f'{ value } '
509511 return sql_query
510-
511512
512513 # What-If Form CallBack
513514 @app .callback (
@@ -555,25 +556,22 @@ def update_impact_graph(*values):
555556 df .columns = self .param ["columns" ]
556557 array = self .calculate_prediction_shap (df )
557558
558- #Y_Pred
559- #Probability_
559+ # Y_Pred
560+ # Probability_
560561 if self .param ["is_classification" ]:
561- y_and_prob = []
562+ y_and_prob = []
562563 y_and_prob .append (int (array ["y_prediction" ]))
563- y_and_prob .append (round (float (array ["Probability_" + str (int (array ["y_prediction" ])) ]),2 ))
564+ y_and_prob .append (round (float (array ["Probability_" + str (int (array ["y_prediction" ]))]), 2 ))
564565 else :
565566 y_and_prob = []
566- y_and_prob .append (round (float (array ["y_prediction" ]),2 ))
567+ y_and_prob .append (round (float (array ["y_prediction" ]), 2 ))
567568
568569 # figure, dat = g.feature_impact_old(array)
569570 figure , dat = g .local_feature_impact_graph (array )
570571 message = self .insights .insight_2_local_feature_impact (dat , y_and_prob )
571572
572-
573-
574573 return figure , message [0 ], message [1 ], message [2 ], message [3 ]
575574
576-
577575 # Prototypical Analysis
578576 """
579577 Change this. Take input from what-if from
@@ -606,7 +604,7 @@ def update_table(*values):
606604 sample_row = sample_row .to_frame ()
607605 sample_row .rename (columns = {sample_row .columns [0 ]: "orig" }, inplace = True )
608606 sample_row .reset_index (inplace = True )
609- #print(sample_row.columns)
607+ # print(sample_row.columns)
610608 dat = pd .merge (dat , sample_row , on = ['index' ], how = 'left' )
611609 dat ['orig' ] = dat ['orig' ].astype (float )
612610 for i in list (dat .columns ):
@@ -638,7 +636,7 @@ def update_graphs(sql_query, value):
638636 graph_type = "feature_importance"
639637 dff = self .caching_data_manager (df , sql_query , graph_type , g .feature_importance )
640638 message = self .insights .insight_1_feature_imp (dff )
641- figure = g .global_feature_importance_graph (dff , self .param ["is_classification" ])
639+ figure = g .global_feature_importance_graph (dff , self .param ["is_classification" ])
642640 return figure , message [0 ]
643641
644642 # Global Feature Impact
@@ -661,7 +659,7 @@ def update_graphs(sql_query, value):
661659 @app .callback (
662660 Output ('indicator-graphic' , 'figure' ),
663661 [Input ('xaxis-column' , 'value' ),
664- # Input('yaxis-column', 'value'),
662+ # Input('yaxis-column', 'value'),
665663 Input ('third-axis' , 'value' ),
666664 Input ('sql-query-button' , 'children' )])
667665 def update_graph (xaxis_column_name , third_axis_name , sql_query ):
@@ -675,7 +673,7 @@ def update_graph(xaxis_column_name, third_axis_name, sql_query):
675673 graph_type = 'pdp'
676674 df3 = self .caching_data_manager (df , sql_query , graph_type , g .partial_dependence_plot )
677675 print (df3 )
678- fig = g .pdp_plot (df3 , df3 [xaxis_column_name ], df3 [xaxis_column_name + "_impact" ], df3 [third_axis_name ])
676+ fig = g .pdp_plot (df3 , df3 [xaxis_column_name ], df3 [xaxis_column_name + "_impact" ], df3 [third_axis_name ])
679677 return fig
680678
681679 # Summary Plot
@@ -684,7 +682,6 @@ def update_graph(xaxis_column_name, third_axis_name, sql_query):
684682 [Input ('sql-query-button' , 'children' ),
685683 Input ('xaxis-column-test' , 'value' )])
686684 def update_graph2 (sql_query , value ):
687-
688685
689686 g = plotly_graphs ()
690687 graph_type = 'summary_plot'
@@ -710,48 +707,52 @@ def update_graph2(xaxis_column_name, plot_type, sql_query):
710707 num_variables .append (i )
711708
712709 if plot_type == "Histogram" :
713-
710+
714711 return px .histogram (df3 , x = xaxis_column_name , marginal = "box" , template = "plotly_white" )
715712 else :
716713 for i in cat_variables :
717714 return px .violin (df3 , x = xaxis_column_name , box = True , points = 'all' , template = "plotly_white" )
718715 else :
719716 return px .violin (df3 , y = xaxis_column_name , box = True , points = 'all' , template = "plotly_white" )
720717
721-
722718 # Port Finder
723719 port = 8080
724- debug_value = False
725-
720+ debug_value = False
726721
727722 if mode == "inline" :
728723 try :
729724 app .run_server (mode = "inline" , port = port , debug = debug_value , dev_tools_ui = debug_value ,
730- dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True , dev_tools_hot_reload = True )
725+ dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True ,
726+ dev_tools_hot_reload = True )
731727 except :
732728 port = self .find_free_port ()
733729 app .run_server (mode = "inline" , port = port , debug = debug_value , dev_tools_ui = debug_value ,
734- dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True , dev_tools_hot_reload = True )
730+ dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True ,
731+ dev_tools_hot_reload = True )
735732 else :
736733 try :
737734 app .run_server (host = '0.0.0.0' , port = port , debug = debug_value , dev_tools_ui = debug_value ,
738- dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True , dev_tools_hot_reload = True )
735+ dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True ,
736+ dev_tools_hot_reload = True )
739737 except :
740738 # try different ip in case 0.0.0.0 does not work
741739 try :
742740 try :
743741 port = self .find_free_port ()
744742 app .run_server (host = '0.0.0.0' , port = port , debug = debug_value , dev_tools_ui = debug_value ,
745- dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True , dev_tools_hot_reload = True )
743+ dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True ,
744+ dev_tools_hot_reload = True )
746745 except :
747746 port = self .find_free_port ()
748747 app .run_server (host = '0.0.0.0' , port = port , debug = debug_value , dev_tools_ui = debug_value ,
749- dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True , dev_tools_hot_reload = True )
748+ dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True ,
749+ dev_tools_hot_reload = True )
750750 except :
751751 try :
752752 port = self .find_free_port ()
753753 app .run_server (host = '127.0.0.1' , port = port , debug = debug_value , dev_tools_ui = debug_value ,
754- dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True , dev_tools_hot_reload = True )
754+ dev_tools_props_check = debug_value , dev_tools_silence_routes_logging = True ,
755+ dev_tools_hot_reload = True )
755756 except :
756757 print ("Please restart Jupyter Notebook or Python IDE." )
757758 return False
@@ -812,7 +813,7 @@ def calculate_prediction_shap(self, df):
812813 # prediction col
813814 df_final ["y_prediction" ] = prediction_col
814815
815- if is_classification == True :
816+ if is_classification == True :
816817
817818 # find and add probabilities in the dataset.
818819 prediction_col_prob = self .param ["model" ].predict_proba (df .to_numpy ())
@@ -821,7 +822,6 @@ def calculate_prediction_shap(self, df):
821822 for c in pd_prediction_col_prob .columns :
822823 df_final ["Probability_" + str (c )] = list (pd_prediction_col_prob [c ])
823824
824-
825825 return df_final
826826
827827 def calculate_prediction (self , df ):
0 commit comments