kkhushisaid commited on
Commit
43e6d55
·
verified ·
1 Parent(s): a4f14f7

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -92
app.py DELETED
@@ -1,92 +0,0 @@
1
- import streamlit as st
2
- import numpy as np
3
- import pickle
4
- import streamlit.components.v1 as components
5
- from sklearn.preprocessing import LabelEncoder
6
-
7
- # Load the pickled model
8
- def load_model():
9
- return pickle.load(open('online_payment_fraud_detection_randomforest.pkl', 'rb'))
10
-
11
- # Load the LabelEncoder
12
- def load_label_encoder():
13
- with open('label_encoder.pkl', 'rb') as f:
14
- return pickle.load(f)
15
-
16
- # Function for model prediction
17
- def model_prediction(model, features):
18
- predicted = str(model.predict(features)[0])
19
- return predicted
20
-
21
- def transform(le, text):
22
- text = le.transform(text)
23
- return text[0]
24
-
25
- def app_design(le):
26
- st.subheader("Enter the following values:")
27
-
28
- step = st.number_input("Step: represents a unit of time where 1 step equals 1 hour")
29
-
30
- typeup = st.selectbox('Type of online transaction', ('PAYMENT', 'TRANSFER', 'CASH_OUT', 'DEBIT', 'CASH_IN'))
31
- typeup = transform(le, [typeup])
32
-
33
- amount = st.number_input("The amount of the transaction")
34
-
35
- nameOrig = st.text_input("Transaction ID") # Don't transform
36
- oldbalanceOrg = st.number_input("Balance before the transaction")
37
- newbalanceOrig = st.number_input("Balance after the transaction")
38
-
39
- nameDest = st.text_input("Recipient ID") # Don't transform
40
- oldbalanceDest = st.number_input("Initial balance of recipient before the transaction")
41
- newbalanceDest = st.number_input("The new balance of recipient after the transaction")
42
-
43
- isFlaggedFraud = st.selectbox('IsFlaggedFraud', ('Yes', 'No'))
44
- isFlaggedFraud = transform(le, [isFlaggedFraud])
45
-
46
- # Create a feature list from the user inputs
47
- # ➔ set nameOrig and nameDest as 0
48
- features = [[step, typeup, amount, 0, oldbalanceOrg, newbalanceOrig, 0, oldbalanceDest, newbalanceDest, isFlaggedFraud]]
49
-
50
- # Load the model
51
- model = load_model()
52
-
53
- # Make a prediction when the user clicks the "Predict" button
54
- if st.button('Predict Online Payment Fraud'):
55
- predicted_value = model_prediction(model, features)
56
- if predicted_value == '1':
57
- st.success("⚠️ Online payment fraud detected")
58
- else:
59
- st.success("✅ No online payment fraud detected")
60
-
61
- def about_RamDevs():
62
- components.html("""
63
- <div>
64
- <h4>🚀 Unlock Your Easy Safety with RamDevs Community!</h4>
65
- <p class="subtitle">🔍 Seeking the perfect hassle-free safe online transactions? RamDevs Community is your gateway to easier and safer transactions. Explore free expert sessions, customer support, and password transformation tips.</p>
66
- <p class="subtitle">💼 We offer an upskill program in <b>CyberSecurity, Password management, Legal Terms and Services</b>, and assist customers in <b>security and safer online transactions</b> at minimal development costs.</p>
67
- <p class="subtitle">🆓 Best of all, everything we offer is <b>completely free</b>! We are dedicated to helping society.</p>
68
- <p class="subtitle">Book free of cost 1:1 mentorship on any topic of your choice — <a class="link" href="https://topmate.io/deepakchawla1307">topmate</a></p>
69
- <p class="subtitle">✨ We dedicate over 30 minutes to each applicant’s Password selection, Online profile, mock frauds, and upskill program. If you’d like our guidance, check out our services <a class="link" href="https://RamDevscommunity.wixsite.com/RamDevs">here</a></p>
70
- <p class="subtitle">💡 Join us now, and turbocharge your CyberSecurity!</p>
71
- <p class="subtitle">
72
- <a class="link" href="https://RamDevscommunity.wixsite.com/RamDevs" target="__blank">Website</a>
73
- <a class="link" href="https://www.youtube.com/@RamDevsCommunity1307/" target="__blank">YouTube</a>
74
- <a class="link" href="https://www.instagram.com/RamDevs_community/" target="__blank">Instagram</a>
75
- <a class="link" href="https://medium.com/@RamDevscommunity" target="__blank">Medium</a>
76
- <a class="link" href="https://www.linkedin.com/company/RamDevs-community/" target="__blank">LinkedIn</a>
77
- <a class="link" href="https://github.com/RamDevscommunity" target="__blank">GitHub</a>
78
- </p>
79
- </div>
80
- """, height=600)
81
-
82
- def main():
83
- st.set_page_config(page_title="Online Payment Fraud Detection", page_icon=":chart_with_upwards_trend:")
84
- st.title("Welcome to our Online Payment Fraud Detection App!")
85
-
86
- le = load_label_encoder()
87
- app_design(le)
88
- st.header("About RamDevs Community")
89
- about_RamDevs()
90
-
91
- if __name__ == '__main__':
92
- main()