Issue with importing TextExplainer from eli5.lime package relating to deprecated 'itemfreq' function

765 views Asked by At

I am working on a BERT model for text classification and wish to use TextExplainer for model interpretation. However, when loading the library eli5.lime I receive the following error:

ImportError: cannot import name 'itemfreq' from 'scipy.stats'

It appears that scipy.stats.itemfreq is deprecated and was removed from the latest version of the scipy package. Anyone come across this issue? I note the suggestion is to use np.unique(…, return_counts=True) instead, however, this means updating samplers.py (which I have tried, but came across another indexing error).

Wondering if anyone has come across this one?

1

There are 1 answers

1
f l On
import scipy
import numpy as np
def monkeypath_itemfreq(sampler_indices):
   return zip(*np.unique(sampler_indices, return_counts=True))

scipy.stats.itemfreq=monkeypath_itemfreq