Prasad commited on
Commit
6b74f4e
·
verified ·
1 Parent(s): 8f1e4ae

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +89 -0
README.md CHANGED
@@ -1,2 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # email-spam-classifier-new
2
  End to end code for the email spam classifier project
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: bsd-3-clause
3
+ datasets:
4
+ - Kingsman2125/Spam-MailClassification-Dataset
5
+ language:
6
+ - en
7
+ metrics:
8
+ - accuracy
9
+ - precision
10
+ pipeline_tag: text-classification
11
+ tags:
12
+ - spamClassification
13
+ ---
14
  # email-spam-classifier-new
15
  End to end code for the email spam classifier project
16
+ -----------------------------------------------------
17
+ <!-- TABLE OF CONTENTS -->
18
+ <details>
19
+ <summary>Table of Contents</summary>
20
+ <ol>
21
+ <li>
22
+ <a href="#Quickstart">Quickstart</a>
23
+ </li>
24
+ </ol>
25
+ </details>
26
+
27
+ <!-- Quickstar -->
28
+ ## Quickstart
29
+ ```py
30
+ import streamlit as st
31
+ import pickle
32
+ import string
33
+ import pickle
34
+ from nltk.corpus import stopwords
35
+ import nltk
36
+ from nltk.stem.porter import PorterStemmer
37
+ nltk.download('stopwords') # Downloading stopwords data
38
+ nltk.download('punkt') # Downloading tokenizer data
39
+
40
+ ps = PorterStemmer()
41
+
42
+
43
+ def transform_text(text):
44
+ text = text.lower()
45
+ text = nltk.word_tokenize(text)
46
+
47
+ y = []
48
+ for i in text:
49
+ if i.isalnum():
50
+ y.append(i)
51
+
52
+ text = y[:]
53
+ y.clear()
54
+
55
+ for i in text:
56
+ if i not in stopwords.words('english') and i not in string.punctuation:
57
+ y.append(i)
58
+
59
+ text = y[:]
60
+ y.clear()
61
+
62
+ for i in text:
63
+ y.append(ps.stem(i))
64
+
65
+ return " ".join(y)
66
+
67
+ tfidf = pickle.load(open('vectorizer.pkl','rb'))
68
+ model = pickle.load(open('model.pkl','rb'))
69
+
70
+ st.title("Email/SMS Spam Classifier")
71
+
72
+ input_sms = st.text_area("Enter the message")
73
+
74
+ if st.button('Predict'):
75
+
76
+ # 1. preprocess
77
+ transformed_sms = transform_text(input_sms)
78
+ # 2. vectorize
79
+ vector_input = tfidf.transform([transformed_sms])
80
+ # 3. predict
81
+ result = model.predict(vector_input)[0]
82
+ # 4. Display
83
+ if result == 1:
84
+ st.header("Spam")
85
+ else:
86
+ st.header("Not Spam")
87
+
88
+ ```
89
+
90
+ <p align="right">(<a href="#readme-top">back to top</a>)</p>
91
+