-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfraud_detection.py
More file actions
36 lines (28 loc) · 1.35 KB
/
fraud_detection.py
File metadata and controls
36 lines (28 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import streamlit as st
import pandas as pd
import joblib
model= joblib.load(r"d:\dell_backup_25\d-drive\Masai_Ds\Python\fraud_detection_pipeline_model.pkl")
st.title("Fraud Detection Prediction App")
st.markdown("Please enter the transaction details and use the predict button")
st.divider()
transaction_type = st.selectbox("Transaction Type", ["PAYMENT", "TRANSFER", "CASH_OUT"])
amount = st.number_input("Amount", min_value=0.0, value=1000.0)
oldbalanceOrg=st.number_input("Old Balance (Sender)", min_value=0.0, value=10000.0)
newbalanceOrig=st.number_input("New Balance (Sender)", min_value=0.0, value=9000.0)
oldbalanceDest=st.number_input("Old Balance (Receiver)", min_value=0.0, value=0.0)
newbalanceDest=st.number_input("New Balance (Receiver)", min_value=0.0, value=0.0)
if st.button("Predict"):
input_data = pd.DataFrame([{
"type": transaction_type,
"amount": amount,
"oldbalanceOrg": oldbalanceOrg,
"newbalanceOrig": newbalanceOrig,
"oldbalanceDest": oldbalanceDest,
"newbalanceDest": newbalanceDest
}])
prediction = model.predict(input_data)[0]
st.subheader(f"Prediction : '{int(prediction)}'")
if prediction == 1:
st.error("The transaction can be fraud")
else:
st.success("This transaction looks like it is not a fraud.")