-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprediction.m
More file actions
32 lines (21 loc) · 756 Bytes
/
prediction.m
File metadata and controls
32 lines (21 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
%% SVM SPAM EMAIL CLISSIFICATION EXPERIMENT
%% Predicts whether an email is a spam or not
%% Initialization
clear ; close all; clc
% Set the file to be read in (change this to spamSample2.txt,
% emailSample1.txt or emailSample2.txt to see different predictions on
% different emails types). Try your own emails as well!
load('model.mat');
filename = 'input.txt';
% Read and predict
file_contents = readFile(filename);
word_indices = processEmail(file_contents);
x = emailFeatures(word_indices);
p = svmPredict(model, x);
fprintf('\nProcessed %s\n\nSpam Classification: %d\n', filename, p);
fprintf('(1 indicates spam, 0 indicates not spam)\n\n');
if p==1
fprintf('It is a spam!\n\n');
else
fprintf('It is not a spam!\n\n');
endif