|
import streamlit as st |
|
import numpy as np |
|
import pickle |
|
import streamlit.components.v1 as components |
|
from sklearn.preprocessing import LabelEncoder |
|
le = LabelEncoder() |
|
|
|
|
|
def load_model(): |
|
return pickle.load(open('Online_payment_fraud_detection_randomforest.pkl', 'rb')) |
|
|
|
|
|
def model_prediction(model, features): |
|
predicted = str(model.predict(features)[0]) |
|
return predicted |
|
|
|
def transform(text): |
|
text = le.fit_transform(text) |
|
return text[0] |
|
|
|
|
|
def app_design(): |
|
|
|
image = 'Ramdevs3' |
|
st.image(image, use_column_width=True) |
|
|
|
st.subheader("Enter the following values:") |
|
|
|
step = st.number_input("Step: represents a unit of time where 1 step equals 1 hour") |
|
typeup = st.selectbox('Type of online transaction',('PAYMENT', 'TRANSFER', 'CASH_OUT', 'DEBIT', 'CASH_IN')) |
|
typeup = transform([typeup]) |
|
amount = st.number_input("The amount of the transaction") |
|
nameOrig = st.text_input("Transaction ID") |
|
nameOrig = transform([nameOrig]) |
|
oldbalanceOrg = st.number_input("Balance before the transaction") |
|
newbalanceOrig = st.number_input("Balance after the transaction") |
|
nameDest = st.text_input("Recipient ID") |
|
nameDest = transform([nameDest]) |
|
oldbalanceDest = st.number_input("Initial balance of recipient before the transaction") |
|
newbalanceDest = st.number_input("The new balance of recipient after the transaction") |
|
isFlaggedFraud = st.selectbox('IsFlaggedFraud',('Yes','No')) |
|
isFlaggedFraud = transform([isFlaggedFraud]) |
|
|
|
features = [[step,typeup,amount,nameOrig,oldbalanceOrg,newbalanceOrig,nameDest,oldbalanceDest,newbalanceDest,isFlaggedFraud]] |
|
|
|
|
|
model = load_model() |
|
|
|
|
|
if st.button('Predict Online Payment Fraud'): |
|
predicted_value = model_prediction(model, features) |
|
if predicted_value=='1': |
|
st.success("Online payment fraud not happened") |
|
else: |
|
st.success("Online payment fraud happened") |
|
|
|
def about_RamDevs(): |
|
|
|
components.html(""" |
|
<div> |
|
<h4>🚀 Unlock Your Dream Job with RamDevs Community!</h4> |
|
<p class="subtitle">🔍 Seeking the perfect job? RamDevs Community is your gateway to career success in the tech industry. Explore free expert courses, job-seeking support, and career transformation tips.</p> |
|
<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> |
|
<p class="subtitle">🆓 Best of all, everything we offer is <b>completely free</b>! We are dedicated to helping society.</p> |
|
<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> |
|
<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://RamDevscommunity.wixsite.com/RamDevs">here</a></p> |
|
<p class="subtitle">💡 Join us now, and turbocharge your career!</p> |
|
<p class="subtitle"><a class="link" href="https://RamDevscommunity.wixsite.com/RamDevs" target="__blank">Website</a> |
|
<a class="link" href="https://www.youtube.com/@RamDevsCommunity1307/" target="__blank">YouTube</a> |
|
<a class="link" href="https://www.instagram.com/RamDevs_community/" target="__blank">Instagram</a> |
|
<a class="link" href="https://medium.com/@RamDevscommunity" target="__blank">Medium</a> |
|
<a class="link" href="https://www.linkedin.com/company/RamDevs-community/" target="__blank">LinkedIn</a> |
|
<a class="link" href="https://github.com/RamDevscommunity" target="__blank">GitHub</a></p> |
|
</div> |
|
""", |
|
height=600) |
|
|
|
def main(): |
|
|
|
|
|
st.set_page_config( |
|
page_title="Online Payment Fraud Detection", |
|
page_icon=":chart_with_upwards_trend:", |
|
) |
|
|
|
st.title("Welcome to our Online Payment Fraud Detection App!") |
|
|
|
app_design() |
|
st.header("About RamDevs Community") |
|
about_RamDevs() |
|
|
|
if __name__ == '__main__': |
|
main() |