dsgibbons / shap

A game theoretic approach to explain the output of any machine learning model.
https://shap-community.readthedocs.io/en/latest/
MIT License
25 stars 5 forks source link

Fix failing test from incorrect comparison of bools and ints #77

Closed connortann closed 1 year ago

connortann commented 1 year ago

This fixes a rather subtle bug that was inadvertently introduced by #27.

Related: #4

There is a check whether the variable interactions is equal to 1. Currently, this statment also passes if interactions is equal to True, but this is unintentional. It's a rather nuanced as a bool is a subclass of an int, so isinstance(interactions, int) is not enough.

Side fun fact: this comparison was previously achieved with interactions is 1, which is not safe but may work some of the time depending on the python implmentation. Here's a fun python phenomenon:

>>> a = 1
>>> b = 1
>>> a is b
True
>>> a = 99999999
>>> b = 99999999
>>> a is b
False