Spam consists of unnecessary or inappropriate messages commonly sent to many recipients through electronic channels such as e-mail, telephone, fax, SMS, ICQ, MSN, WhatsApp and Telegram.
An e-mail sent over ARPANET on 1 May 1978 is widely described as the first known spam message. It promoted products and services. Advertising and promotion still account for a substantial portion of spam.
Spam messages commonly deliver identical content to many recipients and often have no value to them. Some contain unlawful or misleading material and create cybersecurity risks.
Ham and Spam
Addresses used for spam can be collected from websites and documents by automated bots. The messages may not provide a valid or functional return address, making retrospective tracing more difficult.
In the United States, ham is a preserved pork product. SPAM, originally associated with “spiced ham,” became a widely recognized brand. The product remains commercially available.
The term spam was later adopted for unwanted and unnecessary messages. Ham became the contrasting term for legitimate messages.
Naive Bayes Classifier
The method is named after the English mathematician Thomas Bayes and is based on Bayes’ theorem.
Despite its simple design and simplifying assumptions, it can produce results better than expected.
Bayes’ theorem relates conditional and marginal probabilities for a random variable.
P(A|B) = P(B|A) P(A) / P(B)
P(A): marginal probability of event A
P(B): marginal probability of event B
P(A|B): probability of A when B has occurred
P(B|A): probability of B when A has occurred
A classification problem contains multiple features and a target variable.
In the corresponding formulation, C represents the target variable and F represents the features.
The Naive Bayes classifier ultimately combines the relevant conditional probabilities.
N-Gram Algorithm
An algorithm used for searching, comparison and frequency analysis over data.
The value `n` represents the degree, while the gram is the corresponding unit. Common forms include:
1-gram: unigram
2-gram: bigram
3-gram: trigram
n-gram
This approach is widely used in text mining and in language models for speech-recognition systems.
Results
Accuracy: 0.9904, ACC = (TP + TN) / (P + N)
Sensitivity: 0.9917, TPR = TP / (TP + FN)
Specificity: 0.9815, SPC = TN / (FP + TN)
Precision: 0.9972, PPV = TP / (TP + FP)
Negative Predictive Value: 0.9465, NPV = TN / (TN + FN)
False-Positive Rate: 0.0185, FPR = FP / (FP + TN)
False-Discovery Rate: 0.0028, FDR = FP / (FP + TP)
False-Negative Rate: 0.0083, FNR = FN / (FN + TP)
F1 Score: 0.9945, F1 = 2TP / (2TP + FP + FN)
Matthews Correlation Coefficient: 0.9584