@@ -573,34 +573,44 @@ def _save_report(
573
573
if self .spec .generate_explanations :
574
574
try :
575
575
if not self .formatted_global_explanation .empty :
576
+ # Round to 4 decimal places before writing
577
+ global_expl_rounded = self .formatted_global_explanation .copy ()
578
+ global_expl_rounded = global_expl_rounded .apply (
579
+ lambda col : np .round (col , 4 ) if np .issubdtype (col .dtype , np .number ) else col
580
+ )
576
581
if self .spec .generate_explanation_files :
577
582
write_data (
578
- data = self . formatted_global_explanation ,
583
+ data = global_expl_rounded ,
579
584
filename = os .path .join (
580
585
unique_output_dir , self .spec .global_explanation_filename
581
586
),
582
587
format = "csv" ,
583
588
storage_options = storage_options ,
584
589
index = True ,
585
590
)
586
- results .set_global_explanations (self . formatted_global_explanation )
591
+ results .set_global_explanations (global_expl_rounded )
587
592
else :
588
593
logger .warning (
589
594
f"Attempted to generate global explanations for the { self .spec .global_explanation_filename } file, but an issue occured in formatting the explanations."
590
595
)
591
596
592
597
if not self .formatted_local_explanation .empty :
598
+ # Round to 4 decimal places before writing
599
+ local_expl_rounded = self .formatted_local_explanation .copy ()
600
+ local_expl_rounded = local_expl_rounded .apply (
601
+ lambda col : np .round (col , 4 ) if np .issubdtype (col .dtype , np .number ) else col
602
+ )
593
603
if self .spec .generate_explanation_files :
594
604
write_data (
595
- data = self . formatted_local_explanation ,
605
+ data = local_expl_rounded ,
596
606
filename = os .path .join (
597
607
unique_output_dir , self .spec .local_explanation_filename
598
608
),
599
609
format = "csv" ,
600
610
storage_options = storage_options ,
601
611
index = True ,
602
612
)
603
- results .set_local_explanations (self . formatted_local_explanation )
613
+ results .set_local_explanations (local_expl_rounded )
604
614
else :
605
615
logger .warning (
606
616
f"Attempted to generate local explanations for the { self .spec .local_explanation_filename } file, but an issue occured in formatting the explanations."
0 commit comments