Spaces:
Sleeping
Sleeping
import gradio as gr | |
import pandas as pd | |
import pickle | |
# Modeli yükle | |
with open('creditcard.pkl', 'rb') as file: | |
model = pickle.load(file) | |
# Tahmin fonksiyonu | |
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): | |
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]], | |
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']) | |
prediction = model.predict(input_data)[0] | |
return 'Fraudulent' if prediction == 1 else 'Not Fraudulent' | |
# Gradio arayüzü | |
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']] | |
outputs = gr.Textbox(label="Prediction") | |
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) | |