The streamllit application is throwing error for the pickle file

i have the code:
import streamlit as st
import pickle
import pandas as pd
import numpy as np

conc = pickle.load(open(‘obligation/Concrete.pkl’, ‘rb’))
def predict_strength(Cement,Blast_furnace_Slag,Fly_Ash,Water,SuperPlasticizer,CoarseAgg,Fine_Agg,Age):
prediction = conc.predict([[Cement,Blast_furnace_Slag,Fly_Ash,Water,SuperPlasticizer,CoarseAgg,Fine_Agg,Age]])
print(prediction)
return prediction

def main():
st.title(“Concrete Strength Prediction”)
Cement= st.text_input(“Cement”,“Type Here”)
Blast_furnace_Slag= st.text_input(“Blast_furnace_Slag”,“Type Here”)
Fly_Ash = st.text_input(“Fly_Ash”, “Type Here”)
Water = st.text_input(“Water”, “Type Here”)
SuperPlasticizer = st.text_input(“Super Plasticizers”, “Type Here”)
CoarseAgg = st.text_input(“Coarse Aggregate”, “Type Here”)
Fine_Agg = st.text_input(“Fine Aggregates”, “Type Here”)
Age = st.text_input(“Age”, “Type Here”)
result =“”
if st.button(“Predict”):
result = predict_strength(Cement,Blast_furnace_Slag,Fly_Ash,Water,SuperPlasticizer,CoarseAgg,Fine_Agg,Age)
st.success(“The output is {}”.format(result))

if name==‘main’:
main()

but when i am running it is showing the error on my browser as:
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’)]

Traceback:

File "C:\Users\soumya sharma\AppData\Local\Programs\Python\Python311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)File "C:\Users\soumya sharma\PycharmProjects\pythonProject1\obligation\pages\07_Concrete.py", line 9, in <module>
    conc = pickle.load(open('obligation/Concrete.pkl', 'rb'))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "sklearn\tree\_tree.pyx", line 728, in sklearn.tree._tree.Tree.__setstate__File "sklearn\tree\_tree.pyx", line 1434, in sklearn.tree._tree._check_node_ndar

what is the solution please help

I think this is a related thread:

u should check the version of the Pandas and other libraries which must be same as the localhost…

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