App deployment problem

Hi all can you please help me out with this error???

2023-07-11 11:53:03.220 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
  File "/app/qsar/test.py", line 41, in <module>
    bioactivity_first_model = pickle.load(open('akt_model.pkl', 'rb'))
  File "sklearn/tree/_tree.pyx", line 714, in sklearn.tree._tree.Tree.__setstate__
  File "sklearn/tree/_tree.pyx", line 1418, in sklearn.tree._tree._check_node_ndarray
ValueError: node array from the pickle has an incompatible dtype:
- expected: {'names': ['left_child', 'right_child', 'feature', 'threshold', 'impurity', 'n_node_samples', 'weighted_n_node_samples', 'missing_go_to_left'], 'formats': ['<i8', '<i8', '<i8', '<f8', '<f8', '<i8', '<f8', 'u1'], 'offsets': [0, 8, 16, 24, 32, 40, 48, 56], 'itemsize': 64}
- got     : [('left_child', '<i8'), ('right_child', '<i8'), ('feature', '<i8'), ('threshold', '<f8'), ('impurity', '<f8'), ('n_node_samples', '<i8'), ('weighted_n_node_samples', '<f8')]

The rep is available here

Hi @RATUL_BHOWMIK! :wave:

The issue you’re encountering appears to be due to an incompatibility in the data type (dtype) of the node array while trying to load your model using pickle.

Have you tried to use joblib instead of pickle?

Scikit-learn recommends using joblib for persisting models, as it’s more efficient on objects that carry large numpy arrays.

Try to replace it and let us know? :slight_smile:

Best wishes.
Charly

I am getting the same error, the error was not there two weeks ago. I am trying to load pre-trained model (RandomForest) classifier

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)File "/app/sdsoai-gen-text-models/app.py", line 48, in <module>
    clf_loaded = pickle.load(file)File "sklearn/tree/_tree.pyx", line 714, in sklearn.tree._tree.Tree.__setstate__File "sklearn/tree/_tree.pyx", line 1418, in sklearn.tree._tree._check_node_ndarray

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.