File size: 1,671 Bytes
cb98fa6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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")