44from  shap_pdp  import  * 
55from  summary_plot  import  * 
66from  data_for_shap_graphs  import  * 
7+ import  plotly .graph_objects  as  go 
8+ 
79
810class  plotly_graphs ():
911    def  __init__ (self ):
1012        super (plotly_graphs , self ).__init__ ()
11-         self .data =  data_for_shap_graphs ()
13+         self .data   =  data_for_shap_graphs ()
1214
1315        # save all important variables here. 
1416
15- 
16-     def  feature_importance (self ,  df ):
17+     def  feature_importance (self , df ):
1718        df2  =  self .data .feature_importance (df )
1819
1920        names  =  list (df2 ["VariableName" ])
@@ -24,7 +25,8 @@ def feature_importance(self,  df):
2425
2526        df2 ["VariableName" ] =  new_names 
2627
27-         feature_importance  =  px .bar (df2 , x = 'Impact_Value' , y = "VariableName" , orientation = 'h' , title = 'Feature Importance' ,)
28+         feature_importance  =  px .bar (df2 , x = 'Impact_Value' , y = "VariableName" , orientation = 'h' ,
29+                                     title = 'Feature Importance' , )
2830        return  feature_importance , df2 
2931
3032    def  feature_impact (self , df ):
@@ -45,21 +47,31 @@ def feature_impact(self, df):
4547
4648    def  summary_plot (self , df ):
4749        df2  =  self .data .summary_plot (df )
50+         # summary_plot = go.Figure() 
51+        
4852
53+         # summary_plot.add_trace(go.Scattergl(x=df2['xaxis'], y=df2['yaxis'], 
54+         #                                     mode='markers',hovertext=df2['hover'], 
55+         #                                     marker=dict(color=list(df2['color']),showscale=True,autocolorscale=False, 
56+         #                                                 cauto=False))) 
4957        summary_plot  =  px .scatter (df2 , x = "xaxis" , y = "yaxis" , color = "color" , hover_data = ["hover" ])
5058
5159        return  summary_plot , df2 
5260
5361    def  partial_dependence_plot (self , df , v1 , v2 , v3 ):
5462        pdp  =  shap_pdp ()
5563        df  =  pdp .find (df )
56-         g =  px .scatter (df , x = v1 , y = v2 , color = v3 )
64+         g  =  go .Figure ()
65+         print ("new" )
66+         # g.add_trace(go.Scattergl(x=df[v1], y=df[v2], mode='markers',showlegend=True, 
67+         #                                     marker=dict(color=list(df[v3]), 
68+         #                                                 autocolorscale=False, 
69+         #                                                 cauto=False 
70+         #                                                 ))) 
71+ 
72+         g  =  px .scatter (df , x = v1 , y = v2 , color = v3 )
5773        return  g , df 
5874
59- 
6075    def  distributions (self , df , variable_name ):
61-         graph =  px .histogram (df , x = variable_name , marginal = "box" )
76+         graph   =  px .histogram (df , x = variable_name , marginal = "box" )
6277        return  graph 
63- 
64- 
65- 
0 commit comments