AyushAI14's picture
Upload 2 files
cb98fa6 verified
import streamlit as st
import pandas as pd
import numpy as np
import joblib
model = joblib.load('Fraud_txn_detection_xgboost.pkl')
st.title('Fraud Transaction detector ')
st.markdown("Please fill in the detail and press predict")
st.divider()
import streamlit as st
import numpy as np
import pandas as pd
st.title("Fraud Detection Input Form")
type_map = {"TRANSFER": 0, "CASH_OUT": 1}
type_choice = st.selectbox("Transaction Type", options=list(type_map.keys()))
type_val = type_map[type_choice]
amount = st.number_input("Transaction Amount", min_value=0.0, value=1000.0)
oldbalanceOrg = st.number_input("Old Balance (Origin)", min_value=0.0, value=5000.0)
newbalanceOrig = st.number_input("New Balance (Origin)", min_value=0.0, value=4000.0)
oldbalanceDest = st.number_input("Old Balance (Destination)", min_value=0.0, value=0.0)
newbalanceDest = st.number_input("New Balance (Destination)", min_value=0.0, value=1000.0)
errordiffbalanceOrg = newbalanceOrig + amount - oldbalanceOrg
errordiffbalanceDest = oldbalanceDest + amount - newbalanceDest
if st.button("Predict"):
input_data = pd.DataFrame([{
'type': type_val,
'amount': amount,
'oldbalanceOrg': oldbalanceOrg,
'newbalanceOrig': newbalanceOrig,
'oldbalanceDest': oldbalanceDest,
'newbalanceDest': newbalanceDest,
'errordiffbalanceOrg': errordiffbalanceOrg,
'errordiffbalanceDest': errordiffbalanceDest
}])
prediction = model.predict(input_data)[0]
st.subheader(f"Prediction : {prediction}")
if prediction ==1:
st.error("This Transaction is fraud")
else:
st.success("Transaction is not fraud")