Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Code is below:

with open('models/shap_explainer.pkl', 'rb') as f:
    explainer = pickle.load(f)
with open('models/adult_model.pkl', 'rb') as f:
    adult_model = pickle.load(f)

Erro like this:

AttributeError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_3264\2761765422.py in <module> 16 shap_values = pickle.load(f) 17 with open('models/shap_explainer.pkl', 'rb') as f: ---> 18 explainer = pickle.load(f) 19 with open('models/adult_model.pkl', 'rb') as f: 20 adult_model = pickle.load(f)

D:\Software\Anaconda3\envs\iAI\lib\site-packages\numba\serialize.py in <module> 18 from types import FunctionType, ModuleType ---> 20 from . import bytecode, compiler

D:\Software\Anaconda3\envs\iAI\lib\site-packages\numba\compiler.py in <module> 9 from numba import (bytecode, interpreter, postproc, typing, utils, config, 10 errors,) ---> 11 from numba.targets import cpu, callconv 12 from numba.parfor import ParforDiagnostics 13 from numba.inline_closurecall import InlineClosureCallPass

D:\Software\Anaconda3\envs\iAI\lib\site-packages\numba\targets\cpu.py in <module> 9 from numba import _dynfunc, config 10 from numba.callwrapper import PyCallWrapper ---> 11 from .base import BaseContext, PYOBJECT 12 from numba import utils, cgutils, types 13 from numba.utils import cached_property

D:\Software\Anaconda3\envs\iAI\lib\site-packages\numba\targets\base.py in <module> 23 builtin_registry, impl_ret_borrowed, 24 RegistryLoader) ---> 25 from numba import datamodel 27 GENERIC_POINTER = Type.pointer(Type.int(8))

D:\Software\Anaconda3\envs\iAI\lib\site-packages\numba\datamodel\_init_.py in <module> 2 from .packer import ArgPacker, DataPacker 3 from .registry import register_default, default_manager, register ----> 4 from .models import PrimitiveModel, CompositeModel, StructModel

D:\Software\Anaconda3\envs\iAI\lib\site-packages\numba\datamodel\models.py in <module> 304 @register_default(types.ExceptionInstance) 305 @register_default(types.ExternalFunction) --> 306 @register_default(types.Macro) 307 @register_default(types.EnumClass) 308 @register_default(types.IntEnumClass)

AttributeError: module 'numba.types' has no attribute 'Macro'

I have no idea with it , i have searched for the solution but found nothing about it.

Please help to load above 2 pkl file successfully

If you try to use such a code in a jitted Numba function, then you certainly need to read the documentation more carefully. Numba is not designed to execute such a thing. It is mainly designed to speed up Numpy based codes, not general-purpose Python code. If you want a general purpose-JIT, then you need to use another interpreter such as PyPy, but you will certainly get other issue: many packages does not support PyPy because people focus on mainly on the standard CPython interpreter. Anyway, I doubt PyPy could help here since it should be vectorized function, and even IO-bound ones... – Jérôme Richard Jan 24 at 10:03

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.