|
| 1 | + |
| 2 | +import streamlit as st |
| 3 | +import pandas as pd |
| 4 | +import joblib |
| 5 | + |
| 6 | + |
| 7 | +model = joblib.load("fraud_detection_pipeline.pkl") |
| 8 | + |
| 9 | +st.title("Fraud Detection Predictiion Application") |
| 10 | + |
| 11 | +st.markdown("Please enter the prediction details and use the predict button. ") |
| 12 | + |
| 13 | +st.divider() |
| 14 | + |
| 15 | +transaction_type= st.selectbox("Transaction Type",["PAYMENT","TRANSFER","CASH-OUT","DEPOSIT"]) |
| 16 | + |
| 17 | +amount = st.number_input("Amount", min_value= 0.0, value=1000.0) |
| 18 | + |
| 19 | +oldbalanceOrg = st.number_input("Old BAlance (Sender)",min_value = 0.0, value=10000.0) |
| 20 | + |
| 21 | +newbalanceOrig = st.number_input("New Balance (Sender)", min_value=0.0,value=10000.0) |
| 22 | + |
| 23 | +oldbalanceDest = st.number_input("Old balance (Receiver)", min_value=0.0, value = 0.0) |
| 24 | + |
| 25 | +newbalanceDest = st.number_input("New balance (Receiver)",min_value=0.0,value= 0.0) |
| 26 | + |
| 27 | + |
| 28 | +# now we'l define the prediction button |
| 29 | + |
| 30 | +if st.button("Predict"): |
| 31 | + input_data = pd.DataFrame([{ |
| 32 | + |
| 33 | + "type": transaction_type, |
| 34 | + "amount" : amount, |
| 35 | + "oldbalanceOrg" : oldbalanceOrg, |
| 36 | + "newbalanceOrig" : newbalanceOrig, |
| 37 | + "oldbalanceDest" : oldbalanceDest, |
| 38 | + "newbalanceDest" : newbalanceDest |
| 39 | + |
| 40 | + |
| 41 | + }]) |
| 42 | + |
| 43 | + |
| 44 | + prediction = model.predict(input_data)[0] |
| 45 | + |
| 46 | + st.subheader(f"Prediction : '{int(prediction)}'") |
| 47 | + |
| 48 | + if prediction == 1: |
| 49 | + st.error("This trasaction can be fraud") |
| 50 | + |
| 51 | + else: |
| 52 | + st.success("This transaction doesn't look like fraud.") |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
0 commit comments