Spam Email Classifier

Artificial intelligence is the next big thing in tech. Most likely you have an Gmail account. From pigeons carriers to telegrams, communication has taken many forms through the course of history. Now, everyone uses electronic-mail, or email, as it’s commonly referred to. In many popular email management programs, such as Gmail, by Google, the applications have built-in classifiers that sort your emails into various categories to make them easy to find. One of these classification is whether or not the email is spam.

However these programs are not foolproof. One example of this, is when you try to reset your password at a website. Let’s say you try to log into your Medium account, but it says you entered you password incorrectly. You hit the “forgot password” button and you are informed that an email has been sent to you with instructions to reset your password. When you go to your email management program you do not find your email in your inbox. This often happens because the email was sent by a bot and was classified as spam. This is one of many cases where the email classifier mistakes important emails as spam, or vice versa. My app can distinguish between ham and spam emails accurately, reducing the time spent scrolling in the spam category looking for your emails. The code for my program is available on GitHub ( In my app, the user inputs the contents of an email. Then the code determines the number of unique words in the email, based on these features the code makes a call to the AI, which determines whether or not the email is spam.

The AI takes in the content of the email and extracts the number of unique words there are. It also takes into account the total amount of words, and using these 2 features the AI determines whether the email is spam or ham.

One mistake I made, is that in the training dataset there were too many examples of ham and not enough of spam, resulting in the AI always predicting ham. I fixed this my modifying my dataset to include the same amount of examples of ham and spam.

I have learned much, in my experience of creating my application. I hope to extend my application in the future and who knows it may grow and become something larger. But it is clear that AI is the future.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store