4
4
from shap_pdp import *
5
5
from summary_plot import *
6
6
from data_for_shap_graphs import *
7
+ import plotly .graph_objects as go
8
+
7
9
8
10
class plotly_graphs ():
9
11
def __init__ (self ):
10
12
super (plotly_graphs , self ).__init__ ()
11
- self .data = data_for_shap_graphs ()
13
+ self .data = data_for_shap_graphs ()
12
14
13
15
# save all important variables here.
14
16
15
-
16
- def feature_importance (self , df ):
17
+ def feature_importance (self , df ):
17
18
df2 = self .data .feature_importance (df )
18
19
19
20
names = list (df2 ["VariableName" ])
@@ -24,7 +25,8 @@ def feature_importance(self, df):
24
25
25
26
df2 ["VariableName" ] = new_names
26
27
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' , )
28
30
return feature_importance , df2
29
31
30
32
def feature_impact (self , df ):
@@ -45,21 +47,31 @@ def feature_impact(self, df):
45
47
46
48
def summary_plot (self , df ):
47
49
df2 = self .data .summary_plot (df )
50
+ # summary_plot = go.Figure()
51
+
48
52
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)))
49
57
summary_plot = px .scatter (df2 , x = "xaxis" , y = "yaxis" , color = "color" , hover_data = ["hover" ])
50
58
51
59
return summary_plot , df2
52
60
53
61
def partial_dependence_plot (self , df , v1 , v2 , v3 ):
54
62
pdp = shap_pdp ()
55
63
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 )
57
73
return g , df
58
74
59
-
60
75
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" )
62
77
return graph
63
-
64
-
65
-
0 commit comments