Roboticol's picture
Create app.py
8ad4367 verified
import gradio as gr
import joblib
model = joblib.load("news_model.joblib")
vectorizer = joblib.load("news_vectorizer.joblib")
def predict_news(text):
if not text.strip():
return "Please enter some text"
user_tfidf = vectorizer.transform([text])
prediction = model.predict(user_tfidf)[0]
proba = model.predict_proba(user_tfidf)[0]
label = "REAL NEWS ✅" if prediction == 1 else "FAKE NEWS ❌"
confidence = round(max(proba) * 100, 2)
return f"{label} (Confidence: {confidence}%)"
iface = gr.Interface(
fn=predict_news,
inputs="text",
outputs="text",
title="Fake News Detector",
description="Enter a news headline or short text and this AI will tell you if it's real or fake."
)
iface.launch()