import streamlit as st import numpy as np import pickle import streamlit.components.v1 as components from sklearn.preprocessing import LabelEncoder # Load the pickled model def load_model(): return pickle.load(open('online_payment_fraud_detection_randomforest.pkl', 'rb')) # Load the LabelEncoder def load_label_encoder(): with open('label_encoder.pkl', 'rb') as f: return pickle.load(f) # Function for model prediction def model_prediction(model, features): predicted = str(model.predict(features)[0]) return predicted def transform(le, text): text = le.transform(text) return text[0] def app_design(le): # Add input fields for High, Open, and Low values image = 'Ramdevs2' 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(le, [typeup]) amount = st.number_input("The amount of the transaction") nameOrig = st.text_input("Transaction ID") nameOrig = transform(le, [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(le, [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(le, [isFlaggedFraud]) # Create a feature list from the user inputs features = [[step, typeup, amount, nameOrig, oldbalanceOrg, newbalanceOrig, nameDest, oldbalanceDest, newbalanceDest, isFlaggedFraud]] # Load the model model = load_model() # Make a prediction when the user clicks the "Predict" button 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("""
🔍 Seeking the perfect advisors for better safety? RamDevs Community is your gateway to success in a safe society. Explore free expert sessions, customer support, and password transformation tips.
đź’Ľ We offer many programs in Fraud Detection, CyberSecurity knowledge, Password encryption, and assist customers in adopting ALL THIS free of costs.
🆓 Best of all, everything we offer is completely free! We are dedicated to helping society.
Book free of cost 1:1 mentorship on any topic of your choice — topmate
✨ We dedicate over 30 minutes to each applicant’s Passwords, Previous Transactions, mock fraud transactions, and much more. If you’d like our guidance, check out our services here
đź’ˇ Join us now, and turbocharge your career!