akarshan11 commited on
Commit
889d06e
·
verified ·
1 Parent(s): adbbd3e

Delete main.py

Browse files
Files changed (1) hide show
  1. main.py +0 -56
main.py DELETED
@@ -1,56 +0,0 @@
1
- import streamlit as st
2
- import pickle
3
- import string
4
- from nltk.corpus import stopwords
5
- import nltk
6
- from nltk.stem.porter import PorterStemmer
7
-
8
- ps = PorterStemmer()
9
-
10
- def transform_text(text):
11
- text = text.lower()
12
- text = nltk.word_tokenize(text)
13
-
14
- y = []
15
- for i in text:
16
- if i.isalnum():
17
- y.append(i)
18
-
19
- text = y[:]
20
- y.clear()
21
-
22
- for i in text:
23
- if i not in stopwords.words('english') and i not in string.punctuation:
24
- y.append(i)
25
-
26
- text = y[:]
27
- y.clear()
28
-
29
- for i in text:
30
- y.append(ps.stem(i))
31
-
32
- return ' '.join(y)
33
-
34
- tfidf = pickle.load(open('vectorizer.pkl', 'rb'))
35
- model = pickle.load(open('model.pkl', 'rb'))
36
-
37
- st.title("Email/SMS SPAM Classifier")
38
-
39
- input_sms = st.text_area("Enter the message")
40
-
41
- if st.button('Predict'):
42
-
43
- # 1. preprocess
44
- transform_sms = transform_text(input_sms)
45
- # 2. vectorize
46
- vector_input = tfidf.transform([transform_sms])
47
- # 3. predict
48
- result = model.predict(vector_input)[0]
49
- # 4. Display
50
- if result == 1:
51
- st.header("Spam")
52
- else:
53
- st.header("Not Spam")
54
-
55
-
56
-