Upload 3 files
Browse files- Online_payment_fraud_detection_randomforest.pkl +3 -0
- app (1).py +93 -0
- requirements.txt +4 -0
Online_payment_fraud_detection_randomforest.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3c249f68b5bf4dd685f77507b7d3e3ab25874029653bd71b98c8a6124a5ab32e
|
3 |
+
size 183015
|
app (1).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: represents a unit of time where 1 step equals 1 hour")
|
30 |
+
typeup = st.selectbox('Type of online transaction',('PAYMENT', 'TRANSFER', 'CASH_OUT', 'DEBIT', 'CASH_IN'))
|
31 |
+
typeup = transform([typeup])
|
32 |
+
amount = st.number_input("The amount of the transaction")
|
33 |
+
nameOrig = st.text_input("Transaction ID")
|
34 |
+
nameOrig = transform([nameOrig])
|
35 |
+
oldbalanceOrg = st.number_input("Balance before the transaction")
|
36 |
+
newbalanceOrig = st.number_input("Balance after the transaction")
|
37 |
+
nameDest = st.text_input("Recipient ID")
|
38 |
+
nameDest = transform([nameDest])
|
39 |
+
oldbalanceDest = st.number_input("Initial balance of recipient before the transaction")
|
40 |
+
newbalanceDest = st.number_input("The new balance of recipient after the transaction")
|
41 |
+
isFlaggedFraud = st.selectbox('IsFlaggedFraud',('Yes','No'))
|
42 |
+
isFlaggedFraud = transform([isFlaggedFraud])
|
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 Payment Fraud Detection App!")
|
87 |
+
|
88 |
+
app_design()
|
89 |
+
st.header("About HiDevs Community")
|
90 |
+
about_hidevs()
|
91 |
+
|
92 |
+
if __name__ == '__main__':
|
93 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
scikit-learn==1.1.2
|
4 |
+
|