-
Notifications
You must be signed in to change notification settings - Fork 0
/
FraudDetection_Deploy.py
56 lines (43 loc) · 1.76 KB
/
FraudDetection_Deploy.py
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
import pickle
import streamlit as st
#loading in the model to predict
pickle_in = open('FraudDataClassifier.pkl', 'rb')
FraudDataClassifier = pickle.load(pickle_in)
def prediction(transactiontype, amount, oldbalanceorg, oldbalancedest, newbalanceorg, newbalancedest):
#transaction type
if transactiontype == 'CASH_IN':
transactiontype = 0
elif transactiontype == 'CASH_OUT':
transactiontype = 1
elif transactiontype == 'DEBIT' :
transactiontype = 2
elif transactiontype == 'PAYMENT' :
transactiontype = 3
else:
transactiontype = 4
amount = float(amount)
oldbalanceorg = float(oldbalanceorg)
oldbalancedest = float(oldbalancedest)
newbalanceorg = float(newbalanceorg)
newbalancedest = float(newbalancedest)
prediction = FraudDataClassifier.predict([[transactiontype, amount, oldbalanceorg, oldbalancedest, newbalanceorg, newbalancedest]])
return prediction
def main():
html_temp = ""
st.title("Fraud Detection")
st.markdown(html_temp, unsafe_allow_html = True)
transactiontype = st.text_input("Transaction Type")
amount = st.text_input("Amount")
oldbalanceorg = st.text_input("Old Balance Origin")
oldbalancedest = st.text_input("Old Balance Destination")
newbalanceorg = st.text_input("New Balance Origin")
newbalancedest = st.text_input("New Balance Destination")
result = ""
if st.button("Predict"):
result = prediction(transactiontype, amount, oldbalanceorg, oldbalancedest, newbalanceorg, newbalancedest)
if result == 0:
st.success('It is not a Fraud Transaction')
else:
st.success('It is a Fraud Transaction')
if __name__=='__main__':
main()