File size: 1,140 Bytes
c231353
3a0ba24
c231353
3a0ba24
 
 
 
178f876
3a0ba24
c231353
3a0ba24
 
 
 
 
c231353
3a0ba24
 
27ee14b
c231353
3a0ba24
 
 
 
 
c231353
3a0ba24
c231353
3a0ba24
 
 
c231353
3a0ba24
 
 
 
 
c231353
98e13a7
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
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 + INI Dataset")

    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)