Project 4 Approach - Spam or Ham Document Classification

Author

Supriya P.

Introduction (Approach)

For this project, I will build a model that predicts whether an email is spam or ham (not spam). I plan to use the SpamAssassin public corpus, which has folders of emails that are already labeled. I will start with the easy_ham folder and one of the spam folders. Each email is a separate plain text file, so the first step will be reading all of the files into R and labeling each one by the folder it came from.

Most of my work will go into preparing the data. Each email has a header and a body, separated by the first blank line. I plan to split them so I can work with the body text on its own. The header may still be useful, since details like the sender’s domain could help predict spam. Some emails also contain HTML tags, so I will remove those before working with the words.

Next, I will use tidytext to break each email body into words. I plan to make everything lowercase and remove stop words, numbers, and punctuation. Once the data is clean, I will split it into a training set and a test set. I plan to train a simple classifier on the training set and check how well it does on the test set. Because most of the emails are ham, accuracy alone could be misleading. If time allows, I will try building the model with tidymodels but success in this venture is not guaranteed.