code icon indicating copy to clipboard operation
code copied to clipboard

UnpicklingError: NEWOBJ class argument isn't a type object

Open jacobsmith575161 opened this issue 4 years ago • 1 comments

jacobsmith575161 avatar Jul 11 '20 19:07 jacobsmith575161

Hi Data Professor, I followed the instruction in the video tutorial, all went well until i load the model in the streamlit app. I get:

UnpicklingError: NEWOBJ class argument isn't a type object Traceback: File "c:\users\user-pc\appdata\local\programs\python\python37\lib\site-packages\streamlit\ScriptRunner.py", line 322, in _run_script exec(code, module.dict) File "C:\Users\user-pc\Desktop\ML Projects\Expresso_app.py", line 88, in load_clf = pickle.load(open('expresso_churn_model.pkl', 'rb'))

Here's my code:

import streamlit as st import pandas as pd import pickle import numpy as np from xgboost import XGBClassifier

from PIL import Image img = Image.open("logo2.jpg") st.image(img)

st.sidebar.header('User Input features')

def user_input_features(): # REGION = st.sidebar.selectbox('REGION', ('DAKAR','DIOURBEL','FATICK','KAFFRINE','KAOLACK','KEDOUGOU','KOLDA','LOUGA','MATAM','SAINT-LOUIS','SEDHIOU','TAMBACOUNDA','THIES','ZIGUINCHOR'))
# TENURE = st.sidebar.selectbox('TENURE',('D 3-6 month',' E 6-9 month','F 9-12 month','G 12-15 month','H 15-18 month','I 18-21 month','J 21-24 month','K > 24 month')) MONTANT = st.sidebar.slider('MONTANT', 2.0, 4.4, 3.4) FREQUENCE_RECH = st.sidebar.slider('FREQUENCE_RECH', 0.1, 2.5, 0.2) REVENUE = st.sidebar.slider('REVENUE', 0.1, 2.5, 0.2) ARPU_SEGMENT = st.sidebar.slider('ARPU_SEGMENT', 0.1, 2.5, 0.2) FREQUENCE = st.sidebar.slider('FREQUENCE', 0.1, 2.5, 0.2) DATA_VOLUME = st.sidebar.slider('DATA_VOLUME', 0.1, 2.5, 0.2) ON_NET = st.sidebar.slider('ON_NET', 0.1, 2.5, 0.2) ORANGE = st.sidebar.slider('ORANGE', 0.1, 2.5, 0.2) TIGO = st.sidebar.slider('TIGO', 0.1, 2.5, 0.2) ZONE1 = st.sidebar.slider('ZONE1', 0.1, 2.5, 0.2) ZONE2 = st.sidebar.slider('ZONE2', 0.1, 2.5, 0.2) REGULARITY = st.sidebar.slider('REGULARITY', 0.1, 2.5, 0.2) FREQ_TOP_PACK = st.sidebar.slider('FREQ_TOP_PACK', 0.1, 2.5, 0.2) data = { #'REGION': REGION, #'TENURE': TENURE, 'MONTANT': MONTANT, 'FREQUENCE_RECH': FREQUENCE_RECH, 'REVENUE': REVENUE, 'ARPU_SEGMENT': ARPU_SEGMENT, 'FREQUENCE': FREQUENCE, 'DATA_VOLUME': DATA_VOLUME, 'ON_NET': ON_NET, 'ORANGE': ORANGE, 'TIGO': TIGO, 'ZONE1': ZONE1, 'ZONE2': ZONE2, 'REGULARITY': REGULARITY, 'FREQ_TOP_PACK': FREQ_TOP_PACK } features = pd.DataFrame(data, index=[0]) return features

df = user_input_features()

#The Code below is what gives me the error load_clf = pickle.load(open('expresso_churn_model.pkl', 'rb'))

jacobsmith575161 avatar Jul 11 '20 19:07 jacobsmith575161