@@ -192,8 +192,9 @@ def score_to_color(self, score, vmin=-1, vmax=1):
192
192
def print_text_total_attribution (
193
193
self , exp_id : Optional [int ] = None , score_agg : Literal ["mean" , "sum" , "last" ] = "mean"
194
194
):
195
- if exp_id == - 1 :
196
- exp_id = self .df_experiments ["exp_id" ].max ()
195
+
196
+ if exp_id is not None and exp_id < 0 :
197
+ exp_id = self .df_experiments ["exp_id" ].max () + 1 + exp_id
197
198
198
199
token_attrs_df = (
199
200
self .df_input_token_attribution .groupby (["exp_id" , "attribution_strategy" ])
@@ -241,8 +242,8 @@ def print_text_total_attribution(
241
242
self .pretty_print (df )
242
243
243
244
def print_text_attribution_matrix (self , exp_id : int = - 1 ):
244
- if exp_id == - 1 :
245
- exp_id = self .df_experiments ["exp_id" ].max ()
245
+ if exp_id is not None and exp_id < 0 :
246
+ exp_id = self .df_experiments ["exp_id" ].max () + 1 + exp_id
246
247
247
248
matrix = self .get_attribution_matrix (exp_id )
248
249
@@ -285,8 +286,8 @@ def print_total_attribution(
285
286
self , exp_id : Optional [int ] = None , score_agg : Literal ["mean" , "last" ] = "mean"
286
287
):
287
288
totals = []
288
- if exp_id == - 1 :
289
- exp_id = self .df_experiments ["exp_id" ].max ()
289
+ if exp_id is not None and exp_id < 0 :
290
+ exp_id = self .df_experiments ["exp_id" ].max () + 1 + exp_id
290
291
291
292
token_attrs_df = (
292
293
self .df_input_token_attribution .groupby (["exp_id" , "attribution_strategy" ])
@@ -333,8 +334,8 @@ def print_attribution_matrix(
333
334
show_debug_cols : bool = False ,
334
335
score_agg : Literal ["mean" , "last" ] = "mean" ,
335
336
):
336
- if exp_id == - 1 :
337
- exp_id = self .df_experiments ["exp_id" ].max ()
337
+ if exp_id is not None and exp_id < 0 :
338
+ exp_id = self .df_experiments ["exp_id" ].max () + 1 + exp_id
338
339
matrix = self .get_attribution_matrix (
339
340
exp_id , attribution_strategy , show_debug_cols , score_agg
340
341
)
@@ -357,8 +358,8 @@ def get_attribution_matrix(
357
358
show_debug_cols : bool = False ,
358
359
score_agg : Literal ["mean" , "sum" , "last" ] = "mean" ,
359
360
):
360
- if exp_id == - 1 :
361
- exp_id = self .df_experiments ["exp_id" ].max ()
361
+ if exp_id is not None and exp_id < 0 :
362
+ exp_id = self .df_experiments ["exp_id" ].max () + 1 + exp_id
362
363
363
364
if attribution_strategy is None :
364
365
strategies = self .df_token_attribution_matrix [
0 commit comments