@@ -175,7 +175,10 @@ def test_scenario5(self):
175175 examples = [
176176 ['data/imgs_deepnet.zip' , "data/images/cats/pexels-pixabay-33358.jpg" ,
177177 {"region_score_threshold" : 0.7 },
178- '{"prediction": [{"box": [0.68164, 0.30469, 0.79688, 0.36979], "label": "eye", "score": 0.79633}, {"box": [0.38086, 0.27865, 0.50391, 0.36068], "label": "eye", "score": 0.74563}]}' ]]
178+ ('{"prediction": [{"box": [0.68164, 0.30469, 0.79688, 0.36979], '
179+ '"label": "eye", "score": 0.79633}, '
180+ '{"box": [0.38086, 0.27865, 0.50391, 0.36068], '
181+ '"label": "eye", "score": 0.74563}]}' )]]
179182 for example in examples :
180183 example = dict (zip (headers , example ))
181184 show_method (self , self .bigml ["method" ], example )
@@ -186,3 +189,32 @@ def test_scenario5(self):
186189 self , example ["input_data" ])
187190 prediction_compare .the_local_regions_prediction_is (
188191 self , example ["prediction" ])
192+
193+ def test_scenario6 (self ):
194+ """
195+ Scenario 6: Successfully creating a prediction from a ShapWrapper of a model in a json file:
196+ Given I create a local model using ShapWrapper from a "<model>" file
197+ When I create a local prediction for "<numpy_input>"
198+ Then the local prediction is "<prediction>"
199+ When I create a local probabilities prediction for "<numpy_input>"
200+ Then the local probabilities prediction is "<proba_prediction>"
201+ """
202+ import numpy as np
203+ show_doc (self .test_scenario6 )
204+ headers = ["file_path" , "numpy_input" , "prediction" , "proba_prediction" ]
205+ examples = [
206+ ['data/iris_model.json' , np .asarray ([np .asarray ([0.5 ,1.0 ,1.0 ])]),
207+ 0. , [0.9818 , 0.00921 , 0.00899 ]]]
208+ for example in examples :
209+ example = dict (zip (headers , example ))
210+ show_method (self , self .bigml ["method" ], example )
211+ prediction_compare .i_create_a_local_shap_wrapper_from_file (
212+ self , example ["file_path" ])
213+ prediction_compare .i_create_a_shap_local_prediction (
214+ self , example ["numpy_input" ])
215+ prediction_compare .the_local_prediction_is (
216+ self , example ["prediction" ])
217+ prediction_compare .i_create_shap_local_probabilities (
218+ self , example ["numpy_input" ])
219+ prediction_compare .the_local_proba_prediction_is (
220+ self , example ["proba_prediction" ])
0 commit comments