Skip to content

Instantly share code, notes, and snippets.

@yogeshnile
Last active July 15, 2020 10:30
Show Gist options
  • Save yogeshnile/8473ef88d5d1e2f1f95091730f4400a7 to your computer and use it in GitHub Desktop.
Save yogeshnile/8473ef88d5d1e2f1f95091730f4400a7 to your computer and use it in GitHub Desktop.
def predict_spam(sample_message):
sample_message = re.sub(pattern='[^a-zA-Z]',repl=' ', string = sample_message)
sample_message = sample_message.lower()
sample_message_words = sample_message.split()
sample_message_words = [word for word in sample_message_words if not word in set(stopwords.words('english'))]
ps = PorterStemmer()
final_message = [ps.stem(word) for word in sample_message_words]
final_message = ' '.join(final_message)
temp = cv.transform([final_message]).toarray()
return classifier.predict(temp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment