AppliedDataSciencePartners/xgboostExplainer

Runs into issues when a feature column already named "tree"

areeves87 opened this issue · 0 comments

Building the explainer relies on creating several new columns with names such as "tree" and "leaf". If those column names are already used in the training dataset, one can run into issues, specifically #23. In my case, I ran into this issue when using the explainer on a Natural Language Processing xgb model. My model was counting the instances of the word "tree" in the document within a column also named "tree".

The error is triggered when trying to row bind the tree_list_breakdown and tree_breakdown lists within the call to buildExplainerFromTreeList. A warning when the dataset already uses column names that include key terms such as "tree", "leaf", and "intercept" would be helpful. Perhaps written into the first few lines of the function.

Similarly, the explainPredictions function uses variable names that can cause issues. In my case, I had a column named "x" in my dataset that caused problems with the "x" used as the iterator in the for loop for going through all the trees.