Mail : “Spam ”or “Ham ”?

Anmol Sharma
Nov 5, 2020

Identify with few lines of Python 🤩

Filter for spams

Ever wondered how our E-mails gets sorted very efficiently most of the times without any prior customer recommendations and other related info !

The answer lies in what is knows as :

Text vectorization along with some magical maths in form of multinomial classifier using naive bayes classification algorithm ….. 😳🙄

Let us understand in a simpler way 😁…

This wonderful stuff is working on a kind of decision making strategy which simply looks for target words(collected initially in training phase) in the mail close to ones found in Spam , if hit then returns a spam as a result otherwise a ham !

There are various options available to us for these kinds of classification problems, here I have used Multinomial Naive Bayes classifier using python.

This is just the main snippet responsible for predicting new mail as spam or ham.

Here in this code predict function is predicting a input text from the user as one of the class [1 : Spam] and [0 : Ham]

Libraries used : sklearn(MultinomialNB, CountVectorizer,test_train_split), pandas(Data Manipulation), pickle(Saving Model)

Full code is available on my github repo 👇

Try it live :

https://share.streamlit.io/anuanmol/spam/main/app.py

Though was a small story just like this dummy project, made out of curiosity !

Give a read and Increase the blood flow in your palms 👏👏 😁

--

--

Anmol Sharma

Machine learning enthusiast | Data science aficionado | Web Designer | Always curious to know something new and innovative