hidevscommunity commited on
Commit
faa4ca4
1 Parent(s): c9dedc1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +93 -0
app.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ le = LabelEncoder()
7
+
8
+ # Load the pickled model
9
+ def load_model():
10
+ return pickle.load(open('Online_payment_fraud_detection_randomforest.pkl', 'rb'))
11
+
12
+ # Function for model prediction
13
+ def model_prediction(model, features):
14
+ predicted = str(model.predict(features)[0])
15
+ return predicted
16
+
17
+ def transform(text):
18
+ text = le.fit_transform(text)
19
+ return text[0]
20
+
21
+
22
+ def app_design():
23
+ # Add input fields for High, Open, and Low values
24
+ image = '26.png'
25
+ st.image(image, use_column_width=True)
26
+
27
+ st.subheader("Enter the following values:")
28
+
29
+ step = st.number_input("Step")
30
+ typeup = st.text_input("Typeup")
31
+ typeup = transform([typeup])
32
+ amount = st.number_input("Amount")
33
+ nameOrig = st.text_input("NameOrig")
34
+ nameOrig = transform([nameOrig])
35
+ oldbalanceOrg = st.number_input("OldbalanceOrg")
36
+ newbalanceOrig = st.number_input("NewbalanceOrig")
37
+ nameDest = st.text_input("NameDest")
38
+ nameDest = transform([nameDest])
39
+ oldbalanceDest = st.number_input("OldbalanceDest")
40
+ newbalanceDest = st.number_input("NewbalanceDest")
41
+ isFlaggedFraud = st.number_input("IsFlaggedFraud")
42
+
43
+ # Create a feature list from the user inputs
44
+ features = [[step,typeup,amount,nameOrig,oldbalanceOrg,newbalanceOrig,nameDest,oldbalanceDest,newbalanceDest,isFlaggedFraud]]
45
+
46
+ # Load the model
47
+ model = load_model()
48
+
49
+ # Make a prediction when the user clicks the "Predict" button
50
+ if st.button('Predict Online Payment Fraud'):
51
+ predicted_value = model_prediction(model, features)
52
+ if predicted_value=='1':
53
+ st.success("Online payment fraud not happened")
54
+ else:
55
+ st.success("Online payment fraud happened")
56
+
57
+ def about_hidevs():
58
+
59
+ components.html("""
60
+ <div>
61
+ <h4>🚀 Unlock Your Dream Job with HiDevs Community!</h4>
62
+ <p class="subtitle">🔍 Seeking the perfect job? HiDevs Community is your gateway to career success in the tech industry. Explore free expert courses, job-seeking support, and career transformation tips.</p>
63
+ <p class="subtitle">💼 We offer an upskill program in <b>Gen AI, Data Science, Machine Learning</b>, and assist startups in adopting <b>Gen AI</b> at minimal development costs.</p>
64
+ <p class="subtitle">🆓 Best of all, everything we offer is <b>completely free</b>! We are dedicated to helping society.</p>
65
+ <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>
66
+ <p class="subtitle">✨ We dedicate over 30 minutes to each applicant’s resume, LinkedIn profile, mock interview, and upskill program. If you’d like our guidance, check out our services <a class="link" href="https://hidevscommunity.wixsite.com/hidevs">here</a></p>
67
+ <p class="subtitle">💡 Join us now, and turbocharge your career!</p>
68
+ <p class="subtitle"><a class="link" href="https://hidevscommunity.wixsite.com/hidevs" target="__blank">Website</a>
69
+ <a class="link" href="https://www.youtube.com/@HidevsCommunity1307/" target="__blank">YouTube</a>
70
+ <a class="link" href="https://www.instagram.com/hidevs_community/" target="__blank">Instagram</a>
71
+ <a class="link" href="https://medium.com/@hidevscommunity" target="__blank">Medium</a>
72
+ <a class="link" href="https://www.linkedin.com/company/hidevs-community/" target="__blank">LinkedIn</a>
73
+ <a class="link" href="https://github.com/hidevscommunity" target="__blank">GitHub</a></p>
74
+ </div>
75
+ """,
76
+ height=600)
77
+
78
+ def main():
79
+
80
+ # Set the app title and add your website name and logo
81
+ st.set_page_config(
82
+ page_title="Online Payment Fraud Detection",
83
+ page_icon=":chart_with_upwards_trend:",
84
+ )
85
+
86
+ st.title("Welcome to our Online Paymment Fraud Detection App!")
87
+
88
+ app_design()
89
+ st.header("About HiDevs Community")
90
+ about_hidevs()
91
+
92
+ if __name__ == '__main__':
93
+ main()