Indrasenareddy2000/Phishing_Email_Detection
0
1import streamlit as st
2import joblib
3
4# Load the trained model
5model = joblib.load("model.pkl")
6
7# Page Configuration
8st.set_page_config(
9 page_title="Phishing Email Detection",
10 page_icon="๐ง",
11 layout="centered"
12)
13
14# Title
15st.title("๐ง Phishing Email Detection")
16st.write("Enter the email content below to check whether it is a **Safe Email** or a **Phishing Email**.")
17
18# Text Area
19email_text = st.text_area(
20 "Enter Email Content",
21 height=250,
22 placeholder="Paste the email subject and body here..."
23)
24
25# Predict Button
26if st.button("Predict"):
27
28 if email_text.strip() == "":
29 st.warning("Please enter an email.")
30 else:
31
32 # Get prediction probabilities
33 prob = model.predict_proba([email_text])[0]
34
35 safe_prob = prob[0]
36 phishing_prob = prob[1]
37
38 # Predict based on probability
39 if safe_prob >= phishing_prob:
40 st.success("โ
Safe Email")
41 else:
42 st.error("๐จ Phishing Email")
43
44 # Show confidence
45 st.subheader("Prediction Confidence")
46
47 st.write(f"โ
Safe Email : **{safe_prob * 100:.2f}%**")
48 st.write(f"๐จ Phishing Email : **{phishing_prob * 100:.2f}%**")
49
50 st.progress(float(max(safe_prob, phishing_prob)))