File size: 949 Bytes
2a0e770
 
 
850dc64
3ef5364
f70f826
2a0e770
850dc64
3cac466
 
850dc64
f70f826
 
850dc64
f70f826
2a0e770
 
850dc64
f70f826
 
 
2a0e770
f70f826
 
 
2a0e770
850dc64
2a0e770
 
f70f826
850dc64
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
import gradio as gr
import pickle

# Load the model and the scaler
with open("fraud_detection_model.pkl", "rb") as f:
    model = pickle.load(f)

with open("scaler.pkl", "rb") as f:
    scaler = pickle.load(f)

# Define a function for prediction
def predict(input_data):
    input_data = [float(x) for x in input_data.split(",")]
    input_data = scaler.transform([input_data])  # Apply the scaling transformation
    prediction = model.predict(input_data)
    return "Fraud" if prediction[0] == 1 else "Not Fraud"

# Updated Gradio Interface
input_text = gr.Textbox(label="Input Features (comma-separated)", placeholder="Enter features like 1.2, 3.4, ...")
output_text = gr.Textbox(label="Prediction")

interface = gr.Interface(
    fn=predict,
    inputs=input_text,
    outputs=output_text,
    title="Fraud Detection System",
    description="Enter the features to predict whether it is fraud or not."
)

# Run the application
interface.launch()