File size: 929 Bytes
cd302d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pickle

# Load the model and vectorizer
with open("model.pkl", "rb") as f:
    model = pickle.load(f)

with open("vectorizer.pkl", "rb") as f:
    vectorizer = pickle.load(f)

# Streamlit App
st.title("📩 SMS Spam Classifier")

st.write("Enter an SMS message below to check whether it's **Spam** or **Not Spam**.")

# Text input box
sms_input = st.text_area("Enter your message here:")

# Predict button
if st.button("Predict"):
    if sms_input.strip() == "":
        st.warning("⚠️ Please enter a message to classify.")
    else:
        # Transform input and predict
        input_vector = vectorizer.transform([sms_input])
        prediction = model.predict(input_vector)[0]

        # Output result
        if prediction == 1:
            st.error("🚫 This message is **Spam**.")
        else:
            st.success("✅ This message is **Not Spam**.")