-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
35 lines (27 loc) · 2.39 KB
/
app.py
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
30
31
32
33
34
35
import streamlit as st
import pickle
import numpy as np
# Load the Naive Bayes model, vectorizer, and feature names
with open('naive_bayes_model.pkl', 'rb') as model_file:
model = pickle.load(model_file)
with open('vectorizer.pkl', 'rb') as vectorizer_file:
vectorizer = pickle.load(vectorizer_file)
# Streamlit app
st.title("Spam Email Detection App")
# Pre-fill the text input with the sample instance
sample_text = (
"Subject: naturally irresistible your corporate identity lt is really hard to recollect a company : the market is full of suqgestions and the information isoverwhelminq ; but a good catchy logo , stylish statlonery and outstanding website will make the task much easier . we do not promise that havinq ordered a iogo your company will automaticaily become a world ieader : it isguite ciear that without good products , effective business organization and practicable aim it will be hotat nowadays market ; but we do promise that your marketing efforts will become much more effective . here is the list of clear benefits : creativeness : hand - made , original logos , specially done to reflect your distinctive company image . convenience : logo and stationery are provided in all formats ; easy - to - use content management system letsyou change your website content and even its structure . promptness : you will see logo drafts within three business days . affordability : your marketing break - through shouldn ' t make gaps in your budget . 100 % satisfaction guaranteed : we provide unlimited amount of changes with no extra fees for you to be surethat you will love the result of this collaboration . have a look at our portfolio _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ not interested . . . _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _"
)
# Input field for the email text
email_text = st.text_area("Enter the email text:", value=sample_text, height=300)
# Predict button
if st.button("Predict"):
# Transform the input text using the loaded vectorizer
input_vector = vectorizer.transform([email_text])
# Make prediction
prediction = model.predict(input_vector)[0]
# Display the result
if prediction == 1:
st.error("The email is predicted to be SPAM.")
else:
st.success("The email is predicted to be NOT SPAM.")