Skip to content

Commit

Permalink
Merge pull request #104 from sharath4444/temp
Browse files Browse the repository at this point in the history
online payment fraud detection using ml algo
  • Loading branch information
abhisek247767 authored Oct 21, 2024
2 parents d913f43 + c751b80 commit 8e0e07a
Show file tree
Hide file tree
Showing 6 changed files with 1,597 additions and 0 deletions.
45 changes: 45 additions & 0 deletions online_payment_fraud_detection/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import streamlit as st
import numpy as np
import pickle

# Load the trained model
with open("fraud_detection_model.pkl", "rb") as file:
model = pickle.load(file)

# Streamlit app title and description
st.title("Online Payment Fraud Detection System")
st.markdown("""
This application predicts whether an online payment transaction is fraudulent based on transaction details.
Enter the transaction information below and click **Predict** to check for fraud.
""")

# Input section for transaction details
st.subheader("Enter Transaction Details")
transaction_type = st.selectbox("Transaction Type", ["CASH_OUT", "PAYMENT", "CASH_IN", "TRANSFER", "DEBIT"], help="Select the type of transaction.")
amount = st.number_input("Transaction Amount", min_value=0.0, format="%.2f", help="Enter the transaction amount.")
oldbalanceOrg = st.number_input("Original Balance (Before Transaction)", min_value=0.0, format="%.2f", help="Enter the account balance before the transaction.")
newbalanceOrig = st.number_input("New Balance (After Transaction)", min_value=0.0, format="%.2f", help="Enter the account balance after the transaction.")

# Map transaction types to numeric values
transaction_map = {"CASH_OUT": 1, "PAYMENT": 2, "CASH_IN": 3, "TRANSFER": 4, "DEBIT": 5}
transaction_type_num = transaction_map[transaction_type]

# Predict fraud when button is clicked
if st.button("Predict"):
# Prepare the input features for prediction
input_features = np.array([[transaction_type_num, amount, oldbalanceOrg, newbalanceOrig]])

# Perform prediction
prediction = model.predict(input_features)

# Display the result
if prediction[0] == "Fraud":
st.error("⚠️ This transaction is predicted as **Fraudulent**!")
else:
st.success("✅ This transaction is predicted as **Not Fraudulent**.")

# Footer
st.markdown("""
---
**Note:** This prediction is based on the trained model and may not be 100% accurate. Use this information as a guide, not a decision-making tool.
""")
Binary file added online_payment_fraud_detection/demo.png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading

0 comments on commit 8e0e07a

Please sign in to comment.