Last active
July 15, 2020 10:30
-
-
Save yogeshnile/8473ef88d5d1e2f1f95091730f4400a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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