Spaces:
Sleeping
Sleeping
File size: 988 Bytes
14173b5 ccb7d79 14173b5 ccb7d79 14173b5 ccb7d79 |
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 |
# Your Gradio app code here
import gradio as gr
import joblib
import numpy as np
from scipy.sparse import hstack
# Load your model and vectorizer
model = joblib.load("spam_classifier_model.joblib")
vectorizer = joblib.load("vectorizer.joblib")
def predict_spam(clean_body, num_urls, has_attachment):
X_text = vectorizer.transform([clean_body])
X_combined = hstack([
X_text,
np.array([num_urls]).reshape(-1, 1),
np.array([has_attachment]).reshape(-1, 1)
])
prediction = model.predict(X_combined)[0]
return "Spam" if prediction == 1 else "Not Spam"
interface = gr.Interface(
fn=predict_spam,
inputs=[
gr.Textbox(lines=5, label="Email Body"),
gr.Slider(0, 50, step=1, label="Number of URLs"),
gr.Radio([0, 1], label="Has Attachment (0 = No, 1 = Yes)")
],
outputs=gr.Text(label="Prediction"),
title="Spam Email Classifier",
description="Classify emails as Spam or Not Spam."
)
interface.launch()
|