@@ -269,6 +269,7 @@ def new_suggestions(
269269 order : SortOrder = "descending" ,
270270 k : int = 50 ,
271271 sort_by_abs : bool = True ,
272+ histogram_bins :int = 100 ,
272273):
273274 f"""Get the comparison between model m1 and m2 on the dataset. Rank the output according to a valid metric
274275
@@ -280,6 +281,7 @@ def new_suggestions(
280281 order (SortOrder, optional): If "ascending", sort in order of least to greatest. Defaults to "descending".
281282 k (int, optional): The number of interesting instances to return. Defaults to 50.
282283 sort_by_abs (bool): Sort by the absolute value. Defaults to True
284+ histogram_bins (int): Number of bins in the returned histogram of all values. Defaults to 100.
283285
284286 Returns:
285287 Object containing information to statically analyze two models.
@@ -289,9 +291,9 @@ def new_suggestions(
289291 ds1 = get_analysis_results (dataset , m1 )
290292 ds2 = get_analysis_results (dataset , m2 )
291293 compared_results = get_comparison_results (m1 , m2 , dataset )
294+ results = np .array (compared_results [metric ])
292295
293296 if sort_by_abs :
294- results = np .array (compared_results [metric ])
295297 results_sign = np .sign (results )
296298 results_abs = np .abs (results )
297299
@@ -341,6 +343,8 @@ def proc_data_row(x1, x2):
341343 ]
342344 ]
343345
346+ histogram_values , bin_edges = np .histogram (results , bins = histogram_bins )
347+
344348 return {
345349 "request" : {
346350 "m1" : m1 ,
@@ -351,6 +355,10 @@ def proc_data_row(x1, x2):
351355 "k" : k ,
352356 },
353357 "result" : result ,
358+ "histogram" : deepdict_to_json ({
359+ "values" : histogram_values ,
360+ "bin_edges" : bin_edges
361+ }, ndigits = 4 )
354362 }
355363
356364
0 commit comments