I am trying to use borutashap for feature selection of a machine learning project. I can't run:
from BorutaShap import BorutaShap
always came across this error:
ImportError: cannot import name 'binom_test' from 'scipy.stats'
I upgraded both borutashap and scipy to make sure they are the latest version. I am using a conda env, and I removed the whole env and recreated a new env and reinstalled all libraries, but still the same mistake. Could anyone help me with this issue? Thank you in advance.
The function scipy.stats.binom_test()
was removed from SciPy 1.12.0. Source.
There is an alternative, scipy.stats.binomtest()
, which is called slightly differently. Here are the docs for old and new.
I believe you could fix this either by downgrading SciPy to 1.11.4 or by applying a fix to BorutaShap to call the new binomial test function.
I believe you'd need to install the package in editable form, then edit Boruta-Shap/src/BorutaShap.py
to do this, on two lines:
Line 9:
Change
from scipy.stats import binom_test, ks_2samp
to
from scipy.stats import binomtest, ks_2samp
Line 885:
Change
return [binom_test(x, n=n, p=p, alternative=alternative) for x in array]
to
return [binomtest(x, n=n, p=p, alternative=alternative).pvalue for x in array]