Value Error dtype='numeric' is not compatible with arrays of bytes/strings.Convert your data to numeric values explicitly instead

Hi Hello im trying to create an email classification model that takes in a user inputted email text or file and tells them whether if its a spam message or not spam message but as I’m testing it I ran into this issue
ValueError: dtype=‘numeric’ is not compatible with arrays of bytes/strings.Convert your data to numeric values explicitly instead.
Heres the link to the github repository below:

If anyone can provide any pointers on how to fix this error or what in my code caused this error that will be greatly appreciated

Hi @Zahid . The problem is that you are not converting your text to vector. Since I have seen your jupyter notebook where you have used tfidf for converting the text to vector right. So you need save the preprocessing as preprocessing.pkl before passing the text to model. So the pipeline should be as follows:-

text input
        |
Transform Method of TFIDF for converting text to vector
        |
Pass the vector to models predict function

Hope you understood

Feel free to ask if it’s not working

Happy Streamlit-ing :balloon:

thank you for your response it worked, but now my issue when i run the same if statement on my file uploader version to check if the text file is also classified as spam or not it’s producing this error
‘UploadedFile’ object has no attribute ‘lower’
the updated code is in the github repository if you would like to check it out and help me tackle this bug it’ll be greatly appreciative

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