CoolFace
Apppublic

Indrasenareddy2000/Phishing_Email_Detection

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
app.py50 linesDownload Raw Back to root
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)))