linkedin / TE2Rules

Python library to explain Tree Ensemble models (TE) like XGBoost, using a rule list.
Other
40 stars 5 forks source link

Extracting Rules #6

Closed waziz786 closed 4 months ago

waziz786 commented 4 months ago

To Whom It May Concern,

I have been facing some issue regarding extracting rules. I am working on a binary classification problem wherein i am classifying emergency department length of stay (LOS) as short or long. I am able to extract rules for the long stay but when i try to flip the signs (change positive class to short stay) i run into a "zero division error". Kindly if you could help me with the issue. Below is the error details.

Kind Regards,

Waqar Aziz

image image image image

groshanlal commented 4 months ago

Thanks for reporting this issue. This issue results from a DivisionByZeroError in one of the log statements.

This happens when you run TE2Rules for too many stages. In some of the later stages, the algorithm has no new rules to find, hence the count_all variable becomes 0, which then results in the DivisionByZeroError in a log statement showing the progress of the algorithm.

I have fixed this issue in my most recent commit and pushed out a new version to pip. To apply the fix, please update to TE2Rules version 0.8.1.

groshanlal commented 4 months ago

As another tip, you can generate the rules explaining the model by running TE2Rules as you have done:

rules = model_explainer.explain(...)

and once the above function has been called, you can refer the rules also here:

rules = model_explainer.rules

As you might already know, this is a short set of representative rules mined by TE2Rules. However, if you want to select the most useful rules yourself from a full list of all possible explaining rules, you can find the longer list of rules here:

rules = model_explainer.longer_rules

Within this extensive set of rules, you have the opportunity to apply your domain knowledge to select those rules that resonate with the decision-making process of a domain expert for the specific task the model is trained for.

While stopping at any stage, you would find lot more rules in the model_explainer.longer_rules than what is directly returned by TE2Rules, providing a wider range of explanations to choose from.

waziz786 commented 4 months ago

Thank you very much for your prompt response. the problem has been resolved by updating the package.

image