Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +49 -0
- preproses.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import pickle
|
| 4 |
+
|
| 5 |
+
# import preproses
|
| 6 |
+
preproses = pickle.load(open("preproses.pkl", "rb"))
|
| 7 |
+
# import model
|
| 8 |
+
model = pickle.load(open("model.pkl", "rb"))
|
| 9 |
+
|
| 10 |
+
#title
|
| 11 |
+
st.title("Online Payments Fraud Detection")
|
| 12 |
+
st.write("Created by Sihar Pangaribuan")
|
| 13 |
+
|
| 14 |
+
# User imput
|
| 15 |
+
step = st.number_input(label='Unit of time (hour)', min_value=1, max_value=143, value=1, step=1)
|
| 16 |
+
type = st.selectbox(label='Select type of online transaction', options=['PAYMENT', 'TRANSFER', 'CASH_OUT', 'DEBIT', 'CASH_IN'])
|
| 17 |
+
amount = st.number_input(label='Input amount of the transaction', min_value=0.1, max_value=10000000.0, value=0.1, step=0.1)
|
| 18 |
+
nameOrig = st.text_input('Input customer origin Id', value='')
|
| 19 |
+
oldbalanceOrg = st.number_input(label='Balance before the transaction', min_value=1.0, max_value=38939424.03, value=1.0, step=1.0)
|
| 20 |
+
newbalanceOrig = st.number_input(label='balance after the transaction', min_value=0.0, max_value=38946233.02, value=0.0, step=0.1)
|
| 21 |
+
nameDest = st.text_input('Input customer destination Id', value='')
|
| 22 |
+
oldbalanceDest = st.number_input(label='Input initial balance of recipient before the transaction', min_value=0.0, max_value=42207404.59, value=0.0, step=0.1)
|
| 23 |
+
newbalanceDest = st.number_input(label='Input the new balance of recipient after the transaction', min_value=0.0, max_value=42207404.59, value=0.0, step=0.1)
|
| 24 |
+
|
| 25 |
+
# Convert ke data frame
|
| 26 |
+
data = pd.DataFrame({'step': [step],
|
| 27 |
+
'type': [type],
|
| 28 |
+
'amount': [amount],
|
| 29 |
+
'nameOrig': [nameOrig],
|
| 30 |
+
'oldbalanceOrg': [oldbalanceOrg],
|
| 31 |
+
'newbalanceOrig': [newbalanceOrig],
|
| 32 |
+
'nameDest': [nameDest],
|
| 33 |
+
'oldbalanceDest': [oldbalanceDest],
|
| 34 |
+
'newbalanceDest': [newbalanceDest]
|
| 35 |
+
})
|
| 36 |
+
|
| 37 |
+
data = preproses.transform(data)
|
| 38 |
+
# model predict
|
| 39 |
+
|
| 40 |
+
if st.button('Predict'):
|
| 41 |
+
prediction = model.predict(data).tolist()[0]
|
| 42 |
+
|
| 43 |
+
if prediction == 1:
|
| 44 |
+
prediction = 'Froud'
|
| 45 |
+
else:
|
| 46 |
+
prediction = 'Not Froud'
|
| 47 |
+
|
| 48 |
+
st.write('The Prediction is: ')
|
| 49 |
+
st.write(prediction)
|
preproses.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:278b2ad56b02da6f89d999a414066c4d1e2db9ee30f28b76eeeae5924fda25e8
|
| 3 |
+
size 3399
|