So I recently completed the Health Cost challenge, now I’m doing the spam classifier. I’ve built a very accurate model. My only problem is I don’t know how to make the predict_message function, that takes a string input, and returns a value(how likely it is to be spam) and a label(‘spam’ or ‘ham’)
The model has a predict() method that takes a message (in a numpy array I believe) and returns its score (in another numpy array I believe). Just take the score and decide when to return ham or spam.
So as I was writing the response to this, I realized that after my if/else statement to determine the point i decide if its ham or spam, I set my prediction variable INSIDE my else statement. Which was giving me a very puzzling “referenced before call” error. Appreciate the responses as always