Skip to content

Commit a9a2c5f

Browse files
Fix sklearn tree importances retrieval bug (#376)
When obtaining the tree feature kpis we access the JSON report path `treePreparationReport.variablesStatistics`. If there are informative variables but no informative tree `variablesStatistics` is not defined. We didn't check that and it lead to a bug in this rare case.
1 parent 82ee065 commit a9a2c5f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

khiops/sklearn/estimators.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,11 @@ def _fit_training_post_process(self, ds):
14351435
else:
14361436
pair_feature_evaluated_names_ = []
14371437
pair_feature_evaluated_levels_ = []
1438-
if "treePreparationReport" in self.model_report_.json_data:
1438+
if (
1439+
"treePreparationReport" in self.model_report_.json_data
1440+
and "variablesStatistics"
1441+
in self.model_report_.json_data["treePreparationReport"]
1442+
):
14391443
tree_preparation_report = self.model_report_.json_data[
14401444
"treePreparationReport"
14411445
]["variablesStatistics"]

0 commit comments

Comments
 (0)