I would like to ask you about an issue I have recently discovered in my Streamlit-shared app. I uploaded the app in May '21 and has been serviceable ever since to the best of my knowledge. However, I attempted to run some tests a couple of weeks ago for a live demonstration at the office, and it failed to show “prediction” results.
AttributeError: Can’t get attribute ‘_rebuild_function’ on <module ‘numba.core.serialize’ from ‘/home/appuser/venv/lib/python3.8/site-packages/numba/core/serialize.py’>
Please, could anybody shed some light to the topic? It would be very much appreciated!
It took me a while come up with a fix. As I understand it, the error is triggered when you try loading your shap treeExplainer with joblib.
I think joblib uses numba to help with unpickling. Although you have pinned the joblib version, the version of numba (which is a joblib dependency) installed is the latest 0.54.1. This latest numba version does not contain the _rebuild_function function in its source code.
One of few versions that work is numba==0.51.0. If you pin this in your requirements file, the error disappears
Here’s the requirements file that worked in my fork:
You’re a genious @snehankekre !! Honestly, I am not very proficient in programming, let alone app development… It is great to see how quickly you came up with a clean solution.
Thank you very much for your time. Have a good day!
In my case, I kept on facing the error above whenever I tried to load the explainers from SHAP. The main reason behind this was the mismatch between the library version used to compile the explainers and the ones used for the Streamlit service. Basically, I had two Conda environments. One for collecting the explainers(Python 3.6), one for Streamlit service(Python >= 3.8). The problem was solved after compiling the explainers with the corresponding Streamlit python version (I assume the scikit learn and SHAP library would adapt to the python version).
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.