-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfraud_detection.py
More file actions
69 lines (29 loc) · 1.42 KB
/
fraud_detection.py
File metadata and controls
69 lines (29 loc) · 1.42 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import streamlit as st
import pandas as pd
import joblib
model = joblib.load("fraud_detection_pipeline.pkl")
st.title("Fraud Detection Predictiion Application")
st.markdown("Please enter the prediction details and use the predict button. ")
st.divider()
transaction_type= st.selectbox("Transaction Type",["PAYMENT","TRANSFER","CASH-OUT","DEPOSIT"])
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=10000.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)
# now we'l define the prediction button
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("This trasaction can be fraud")
else:
st.success("This transaction doesn't look like fraud.")