Spaces:
Sleeping
Sleeping
File size: 1,646 Bytes
9b19228 345b17c 9b19228 51205e3 9b19228 | 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | import streamlit as st
import joblib
from textcleaning import clean_documents
import pandas as pd
model = joblib.load("model.pkl")
st.set_page_config(
page_title="Cyberbullying Detection",
page_icon="🛡️",
layout="centered"
)
st.markdown(
"""
<h1 style='text-align:center;color:#4CAF50;'>
🛡️Cyberbullying Detection & Classification System
</h1>
<p style='text-align:center;font-size:18px;color:gray;'>
Enter a social media message below to detect whether it contains cyberbullying.
</p>
<hr>
""",
unsafe_allow_html=True,
)
user_text = st.text_area(
"✍️ Enter Text",
placeholder="Type or paste a message here...",
height=180
)
col1, col2 = st.columns([1, 1])
with col1:
predict = st.button("🔍 Predict", use_container_width=True)
with col2:
clear = st.button("🗑️ Clear Output", use_container_width=True)
if clear:
st.rerun()
if predict:
if user_text.strip():
user_series = pd.Series([user_text])
with st.spinner("Analyzing text..."):
prediction = model.predict(user_series)[0]
st.markdown("---")
st.subheader("📊 Prediction Result")
if prediction == "not_cyberbullying":
st.success(f"✅ **Prediction:** {prediction}")
else:
st.error(f"🚨 **Prediction:** {prediction}")
else:
st.warning("⚠️ Please enter some text before clicking Predict.")
st.markdown("---")
st.caption("Developed using Streamlit | Scikit-learn | NLP | TF-IDF | Logistic Regression") |