Highlights
Question - Classification Using Rattle
The "spam" concept is diverse: advertisements for products/web sites, make money fast schemes, chain letters, pornography... For background on spam: Cranor, Lorrie F., LaMacchia, Brian A. Spam! Communications of the ACM, 41(8):74-83, 1998.
The following data set was created by Mark Hopkins, Erik Reeber, George Forman, Jaap Suermondt at the Hewlett-Packard Labs in 1999.
“Our collection of spam e-mails came from our postmaster and individuals who had filed spam. Our collection of non-spam e-mails came from filed work and personal e-mails, and hence the word 'george' and the area code '650' are indicators of non-spam. These are useful when constructing a personalized spam filter. One would either have to blind such non-spam indicators or get a very wide collection of non-spam to generate a general purpose spam filter”.
There are 58 variables in this data set. The last column (labelled “spam”) denotes whether the e-mail was considered spam (unsolicited commercial email) or non-spam (genuine email). Most of the attributes (variables) indicate whether a particular word or character was frequently occurring in the e-mail. The run-length attributes (X55-X57) measure the use of capital letters.
Here are the definitions of the attributes – mostly pretty vague. A "word" in this case is any string of alphanumeric characters bounded by non-alphanumeric characters or end-of-string.
X1-X47 = percentage of words in the e-mail that match the “WORD”,
=100*(number of times “WORD” appears in the e-mail) /(total number of words in email)
X48-X53 = percentage of characters in the e-mail that match CHAR,
= 100 * (number of CHAR occurrences) / total characters in e-mail
X54 = average length of uninterrupted sequences of capital letters
X55 = length of longest uninterrupted sequence of capital letters
X56 = sum of length of uninterrupted sequences of capital letters
X57 = total number of capital letters in the e-mail
The variable SPAM is defined as the target variable. All the other variables are interval inputs.
The spam.csv data contains data for a random sample of 4601 emails. Everybody will work with their own random sample of 2000 emails. Note that Rattle will tell you if you need to install additional packages.
a) Choose a random sample consisting of 2000 of these emails using your ID number as the seed. (See R code for this at the end of this assignment). Install the Rattle package if you have not already done so. Read the “ABspam.csv” file into rattle with AB replaced by your initials. Assign appropriate roles to your variables. Your partition should have 70% for training, 15% for validation and 15% for testing. What is the target variable?
b) Now let’s Explore the data. Make sure that the target variable is defined as a categorical variable.
What percentage of your emails are spam?
Is this a reasonably balanced sample? Explain your answer.
c) Produce suitable plots to visualise the differences in the distributions of the X57 variable (total number of capital letters) for emails that were and were not spam. Try to show at least TWO different types of plot.
i) Describe the differences that you see in these distributions.
ii) How do you expect the X57 summary statistics to differ for SPAM and non-SPAM emails?
d) Fit a classification tree for SPAM assuming a loss matrix with a loss of $1 for a false negative (predict Not SPAM when it should predict SPAM) and a loss of $10 for a false positive (predict SPAM when it should be predict Not SPAM). Assume no losses when a correct decision is made. The decisions we make for each email are REJECT (if we predict SPAM) or ACCEPT (if we predict Not SPAM). We want to choose a decision rule that will allow us to minimise the loss associated with our decisions in the long-run.
Answer the following questions.
Complete the following loss table and copy it into your assignment.
Predicted Not SPAM Predicted SPAM
Observed Not SPAM TN=$__ FP=$__
Observed SPAM FN=$__ TP=$__
Which of the above errors is more serious? Why?
e) Now run and draw your tree for the training data, allowing for the inclusion of all input variables. Use all the default settings except make sure that you allow for a depth of only 4 and that you enter the loss matrix correctly (TN, FP, FN, TP). Show this tree in your assignment and all the other associated outputs.
What are the rules for the terminal node with the smallest error rate? What is the decision for this node?
How many splits if we want to minimise the cross-validation error? Explain your answer also explaining what is meant by cross-validation error.
Consider node 1 (root node) of your drawn tree. How many training emails for node 1 and how many of these were spam? What was the decision for all the emails in this node? Was this a surprise? Why?
This IT Assignment has been solved by our IT experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.