Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +21 -0
- creditcard.pkl +3 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import pickle
|
| 4 |
+
|
| 5 |
+
# Modeli yükle
|
| 6 |
+
with open('creditcard.pkl', 'rb') as file:
|
| 7 |
+
model = pickle.load(file)
|
| 8 |
+
|
| 9 |
+
# Tahmin fonksiyonu
|
| 10 |
+
def predict_fraud(Time, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, V14, V15, V16, V17, V18, V19, V20, V21, V22, V23, V24, V25, V26, V27, V28, Amount):
|
| 11 |
+
input_data = pd.DataFrame([[Time, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, V14, V15, V16, V17, V18, V19, V20, V21, V22, V23, V24, V25, V26, V27, V28, Amount]],
|
| 12 |
+
columns=['Time', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'V10', 'V11', 'V12', 'V13', 'V14', 'V15', 'V16', 'V17', 'V18', 'V19', 'V20', 'V21', 'V22', 'V23', 'V24', 'V25', 'V26', 'V27', 'V28', 'Amount'])
|
| 13 |
+
prediction = model.predict(input_data)[0]
|
| 14 |
+
return 'Fraudulent' if prediction == 1 else 'Not Fraudulent'
|
| 15 |
+
|
| 16 |
+
# Gradio arayüzü
|
| 17 |
+
inputs = [gr.Number(label=col) for col in ['Time', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'V10', 'V11', 'V12', 'V13', 'V14', 'V15', 'V16', 'V17', 'V18', 'V19', 'V20', 'V21', 'V22', 'V23', 'V24', 'V25', 'V26', 'V27', 'V28', 'Amount']]
|
| 18 |
+
|
| 19 |
+
outputs = gr.Textbox(label="Prediction")
|
| 20 |
+
|
| 21 |
+
gr.Interface(fn=predict_fraud, inputs=inputs, outputs=outputs, title="Credit Card Fraud Detection", description="Enter the transaction details to predict whether it is fraudulent or not.").launch(share=True)
|
creditcard.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c78f6ab452231e2923e6bcdf994f7cce13edd20e39f97baaa7748948154c0214
|
| 3 |
+
size 180450
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas==1.5.3
|
| 2 |
+
scikit-learn==1.2.2
|
| 3 |
+
xgboost==1.7.6
|
| 4 |
+
gradio==3.34.0
|
| 5 |
+
numpy==1.24.3
|