2
$\begingroup$

I want to classify emails as Spam and Non-Spam.

I have a labelled dataset of 20,000 emails in TXT format. The emails are in individual files and also in one combined file.

An example email looks like this:

From: "Sender Display Name" <sender@abc.com>

To: systudent <systudent@abc.com>, tystudent <tystudent@abc.com>, 
btechstudent <btechstudent@abc.com>, mtech16 <mtech16@abc.com>, mtech17 <mtech17@abc.com>

Subject: Register to the event

Date: Tue, 21 Nov 2017 14:16:17 +0000

X-Originating-IP: [13.90.24.116]


Body:

Some spam text

<https://somelink.com/abc>


EOM
Label: Spam

The features that I want to use are: Sender Display Name, Sender Email address, Receivers, Subject, Date, IP, URL.

How do I convert these to input feature vectors or how can I give these as input which are currently in TXT format, to Machine Learning Algorithms like Random Forest, Naive Bayes, etc. ?

$\endgroup$
3
  • $\begingroup$ Could you please tell if they are all in one file or do you have 20000 different files with one email in each? $\endgroup$ – trollster Dec 19 '17 at 16:00
  • $\begingroup$ @trollster I have them both ways, all in one file, and also 20000 different files with one email in each $\endgroup$ – user5155835 Dec 19 '17 at 17:05
  • $\begingroup$ You should check approaches that use the 20Newsgroups dataset for text classification. For instance: scikit-learn.org/stable/datasets/twenty_newsgroups.html $\endgroup$ – geompalik Jan 2 '18 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.