File size: 684 Bytes
42af868
e07f575
c7d88ae
 
42af868
 
c7d88ae
42af868
 
625ca36
 
c7d88ae
42af868
c7d88ae
42af868
 
 
 
c7d88ae
42af868
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import joblib
import os
import streamlit as st

st.set_page_config(page_title="Simple Model Demo", page_icon="🧠")
st.title("🧠 Simple ML Model (Spam Classifier)")

@st.cache_resource
def load_model():
    model_path = os.path.join(os.path.dirname(__file__), "model", "train.joblib")
    return joblib.load(model_path)

model = load_model()

text = st.text_area("Enter a message", "Win a free iPhone now!")
if st.button("Predict"):
    pred = model.predict([text])[0]
    proba = model.predict_proba([text])[0][1]  # probability of spam (class 1)

    label = "SPAM 🚨" if pred == 1 else "NOT SPAM ✅"
    st.subheader(label)
    st.write(f"Spam probability: **{proba:.2f}**")