Fraud_detection / app.py
oluinioluwa814's picture
Update app.py
98e13a7 verified
import gradio as gr
from main import detect_fraud
def predict(amount, old_balance, new_balance, tx_per_day):
pred, prob, explanation = detect_fraud(
amount, old_balance, new_balance, tx_per_day
)
label = "🚨 FRAUD DETECTED" if pred == 1 else "✅ LEGITIMATE"
return (
label,
f"{prob * 100:.2f}%",
explanation
)
with gr.Blocks() as demo:
gr.Markdown("# 🚨 AI-Powered Fraud Detection System")
gr.Markdown("### Powered by Machine Learning + Gemini AI")
with gr.Row():
amount = gr.Number(label="Transaction Amount ($)")
old_balance = gr.Number(label="Old Balance ($)")
new_balance = gr.Number(label="New Balance ($)")
tx_per_day = gr.Number(label="Transactions per Day")
btn = gr.Button("Analyze Transaction")
output1 = gr.Textbox(label="Prediction")
output2 = gr.Textbox(label="Confidence")
output3 = gr.Textbox(label="AI Explanation")
btn.click(
predict,
inputs=[amount, old_balance, new_balance, tx_per_day],
outputs=[output1, output2, output3]
)
demo.launch(debug=True, share=True)