Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import joblib
|
| 3 |
|
|
@@ -6,16 +7,16 @@ model = joblib.load("fraud_model.pkl")
|
|
| 6 |
|
| 7 |
def predict_fraud(file):
|
| 8 |
df = pd.read_csv(file.name)
|
| 9 |
-
predictions = model.predict(df.drop("Class", axis=1)) #
|
| 10 |
df["Prediction"] = predictions
|
| 11 |
-
return df[df["Prediction"] == 1] # Return only
|
| 12 |
-
|
| 13 |
|
| 14 |
interface = gr.Interface(
|
| 15 |
-
|
| 16 |
fn=predict_fraud,
|
| 17 |
inputs=gr.File(label="Upload CSV File"),
|
| 18 |
outputs=gr.Dataframe(label="Fraudulent Transactions"),
|
| 19 |
title="Fraud Detection System",
|
| 20 |
-
description="Upload a bank
|
| 21 |
-
)
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import joblib
|
| 4 |
|
|
|
|
| 7 |
|
| 8 |
def predict_fraud(file):
|
| 9 |
df = pd.read_csv(file.name)
|
| 10 |
+
predictions = model.predict(df.drop("Class", axis=1)) # Assuming "Class" is present
|
| 11 |
df["Prediction"] = predictions
|
| 12 |
+
return df[df["Prediction"] == 1] # Return only fraud
|
|
|
|
| 13 |
|
| 14 |
interface = gr.Interface(
|
|
|
|
| 15 |
fn=predict_fraud,
|
| 16 |
inputs=gr.File(label="Upload CSV File"),
|
| 17 |
outputs=gr.Dataframe(label="Fraudulent Transactions"),
|
| 18 |
title="Fraud Detection System",
|
| 19 |
+
description="Upload a bank statement (CSV) to detect fraudulent transactions."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
interface.launch()
|