FuurythumbsCPT commited on
Commit
ec8dc2d
·
verified ·
1 Parent(s): d5b74cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
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)) # Drop target column
10
  df["Prediction"] = predictions
11
- return df[df["Prediction"] == 1] # Return only fraudulent predictions
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 transaction CSV file to detect fraud. Ensure the format matches the training dataset (columns V1-V28, Time, Amount, Class)."
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()