linkedin / FastTreeSHAP

Fast SHAP value computation for interpreting tree-based models
BSD 2-Clause "Simplified" License
500 stars 30 forks source link

Remove outdated numpy aliases #21

Closed stephenpardy closed 1 year ago

stephenpardy commented 1 year ago

This PR removes some outdated aliases from the code. Numpy has deprecated np.int np.bool and np.float - these use to just point to the existing python builtin types. This change simply moves the call to these builtins.

Fixes #20

julnow commented 1 year ago

Hi, I came across the same problems. Shouldn't the np.float changed to np.float64, and np.int to np.int32 though? So it's consistent with the rest of the code I proposed another PR https://github.com/linkedin/FastTreeSHAP/pull/22 Please correct me if I'm wrong!

stephenpardy commented 1 year ago

@julnow see discussion in numpy: https://numpy.org/devdocs/release/1.20.0-notes.html#using-the-aliases-of-builtin-types-like-np-int-is-deprecated the np.int np.bool and np.float are all aliasing the python builtins, so to avoid any change in behavior it is recommended to move the regular builtins. Moving to the np.int32 could potentially change behavior, but may be preferred depending on the use case.

julnow commented 1 year ago

@stephenpardy thanks!

jlyang1990 commented 1 year ago

Thanks @stephenpardy for pointing out the outdated numpy aliases issue and making this great PR! I will go and merge it.