ModelOriented / DALEX

moDel Agnostic Language for Exploration and eXplanation
https://dalex.drwhy.ai
GNU General Public License v3.0
1.38k stars 166 forks source link

Compatibility with >= Numpy 2.0.0 (update of ptp method) #571

Closed Chip2916 closed 1 month ago

Chip2916 commented 1 month ago

Hey Dalex team!

Working on a package that has Dalex and Numpy as dependencies and have encountered an issue when using Dalex with >= Numpy 2.0.0.

When calling VariableImportance.plot() an error is raised (see below) due to the use of dl.ptp() here.

This is also present in other scripts such as AggregatedProfiles.plot() here

use of array.ptp() throughout the package would need to be replaced by np.ptp(array) to be compatible with latest numpy versions. This fix should not cause any issues for those who are still using numpy < 2.0.0.

Error:

image

Numpy Doc

As per the numpy migration guide certain methods have been replaced. One of them being array.ptp() being replaced by np.ptp(array)

image

hbaniecki commented 1 month ago

Hi @Chip2916 , big thanks for raising this issue. I shall fix this ASAP (or feel free to contribute a PR with changes like x.ptp() -> np.ptp(x))

Chip2916 commented 1 month ago

No problem, PR raised - also replaced instances of np.Inf with np.inf as latest Numpy releases removed use of np.Inf as part of change to namespaces to avoid multiple ways to access same attribute

hbaniecki commented 1 month ago

Thank you! A new dalex v1.7.1 with the fix is now on PyPI https://pypi.org/project/dalex/1.7.1/