@@ -28,6 +28,7 @@ def explainer():
2828 "predicted_probabilities" ,
2929 "shap_values" ,
3030 "n_features" ,
31+ "needs_support_threshold_prob" ,
3132 "features_table" ,
3233 "exp" ,
3334 ],
@@ -37,7 +38,7 @@ def explainer():
3738 {
3839 "x1" : ["val1" , "val2" , "val3" ],
3940 "x2" : [True , False , True ],
40- "x3" : [2.0 , 1.0 , 0.5 ],
41+ "x3" : [2.0 , 1.0001 , 0.5 ],
4142 "x4" : [1 , 2 , 3 ],
4243 }
4344 ),
@@ -47,39 +48,26 @@ def explainer():
4748 [[1.0 , 0.9 , 0.8 , 0.7 ], [0.0 , - 1.0 , 0.9 , - 0.8 ], [0.25 , 0.0 , - 0.5 , 0.75 ]]
4849 ),
4950 3 ,
51+ 0.5 ,
5052 {
5153 "x1" : {"name" : "feature #1" },
5254 "x2" : {"name" : "feature #2" },
5355 "x3" : {"name" : "feature #3" },
5456 },
5557 pd .DataFrame (
5658 {
57- "Student ID" : [1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 ],
58- "Support Score" : [0.9 , 0.9 , 0.9 , 0.1 , 0.1 , 0.1 , 0.5 , 0.5 , 0.5 ],
59- "Top Indicators" : [
60- "feature #1" ,
61- "feature #2" ,
62- "feature #3" ,
63- "feature #2" ,
64- "feature #3" ,
65- "x4" ,
66- "x4" ,
67- "feature #3" ,
68- "feature #1" ,
69- ],
70- "Indicator Value" : [
71- "val1" ,
72- True ,
73- 2.0 ,
74- False ,
75- 1.0 ,
76- 2 ,
77- 3 ,
78- 0.5 ,
79- "val3" ,
80- ],
81- "SHAP Value" : [1.0 , 0.9 , 0.8 , - 1.0 , 0.9 , - 0.8 , 0.75 , - 0.5 , 0.25 ],
82- "Rank" : [1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 ],
59+ "Student ID" : [1 , 2 , 3 ],
60+ "Support Score" : [0.9 , 0.1 , 0.5 ],
61+ "Support Needed" : [True , False , True ],
62+ "Feature_1_Name" : ["feature #1" , "feature #2" , "x4" ],
63+ "Feature_1_Value" : ["val1" , "False" , "3" ],
64+ "Feature_1_Importance" : [1.0 , - 1.0 , 0.75 ],
65+ "Feature_2_Name" : ["feature #2" , "feature #3" , "feature #3" ],
66+ "Feature_2_Value" : ["True" , "1.0" , "0.5" ],
67+ "Feature_2_Importance" : [0.9 , 0.9 , - 0.5 ],
68+ "Feature_3_Name" : ["feature #3" , "x4" , "feature #1" ],
69+ "Feature_3_Value" : ["2.0" , "2" , "val3" ],
70+ "Feature_3_Importance" : [0.8 , - 0.8 , 0.25 ],
8371 }
8472 ),
8573 ),
@@ -99,14 +87,14 @@ def explainer():
9987 ),
10088 1 ,
10189 None ,
90+ None ,
10291 pd .DataFrame (
10392 {
10493 "Student ID" : [1 , 2 , 3 ],
10594 "Support Score" : [0.9 , 0.1 , 0.5 ],
106- "Top Indicators" : ["x1" , "x2" , "x4" ],
107- "Indicator Value" : ["val1" , False , 3 ],
108- "SHAP Value" : [1.0 , - 1.0 , 0.75 ],
109- "Rank" : [1 , 1 , 1 ],
95+ "Feature_1_Name" : ["x1" , "x2" , "x4" ],
96+ "Feature_1_Value" : ["val1" , "False" , "3" ],
97+ "Feature_1_Importance" : [1.0 , - 1.0 , 0.75 ],
11098 }
11199 ),
112100 ),
@@ -118,6 +106,7 @@ def test_select_top_features_for_display(
118106 predicted_probabilities ,
119107 shap_values ,
120108 n_features ,
109+ needs_support_threshold_prob ,
121110 features_table ,
122111 exp ,
123112):
@@ -127,6 +116,7 @@ def test_select_top_features_for_display(
127116 predicted_probabilities ,
128117 shap_values ,
129118 n_features = n_features ,
119+ needs_support_threshold_prob = needs_support_threshold_prob ,
130120 features_table = features_table ,
131121 )
132122 assert isinstance (obs , pd .DataFrame ) and not obs .empty
0 commit comments