Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose I have a textfile. In the textfile there are many lines and on each lines there is a message and then tab separated showing

Suppose I have a textfile. In the textfile there are many lines and on each lines there is a message and then tab separated showing whether the message is a spam or ham message.

The textfile is as follows:

image text in transcribed

Note that you can get this dataset online from ... kaggle ...

You need to first split the dataset(textfile) into 80% for training and 20% for testing.

From that 80% of training data you need to create 2 arrays :

One array should have only the spam messages.Second array should have only the ham messages.

Sample output:

train_spam = ['send us your password', 'review our website', 'send your password', 'send us your account']

train_ham = ['Your activity report','benefits physical activity', 'the importance vows']

From the remaining 20% of testing data you need to create 1 dictionary:

The dictionary should contain all 20% of data but specifying whether the message is spam or ham.

Sample output

test_messages= {'spam':['renew your password', 'renew your vows'], 'ham':['benefits of our account', 'the importance of physical activity']}

You need to write your program in Python and WITHOUT using any Libraries.Upload a screenshot of your output to show the content of the dictionary and arrays too.I will upvote if it works well.Feel free to ask for clarity.Thanks.

1 ham 2 ham 3 spam 4 ham 5 ham 6 spam 7 ham 8 ham Go until jurong point, crazy.. Available only in bugis n great world la e buffet... Cine there got amore wat... ok lar... Joking wif u oni... Free entry in 2 a wkly comp to win FA Cup final tkts 21st May 2005. Text FA to 87121 to receive entry question(std txt rate)T&C's apply 08452810075over18's U dun say so early hor... U c already then say... Nah I don't think he goes to usf, he lives around here though FreeMsg Hey there darling it's been 3 week's now and no word back! I'd like some fun you up for it still? Tb ok! XxX std chgs to send, 1.50 to rev Even my brother is not like to speak with me. They treat me like aids patent. As per your request 'Melle Melle (Oru Minnaminunginte Nurungu Vettam)' has been set as your callertune for all Callers. Press *9 to copy your friends Callertune

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

using signal flow graph

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago