Commit
•
f464979
1
Parent(s):
1f09dc3
Upload project_app.py
Browse files- project_app.py +35 -0
project_app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import streamlit as st
|
3 |
+
import pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
import pickle
|
6 |
+
|
7 |
+
def main():
|
8 |
+
pickle_in = open('RandomForrestClassifier_df1x.pkl', 'rb')
|
9 |
+
classifier = pickle.load(pickle_in)
|
10 |
+
|
11 |
+
columns = ["V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10",
|
12 |
+
"V11", "V12", "V13", "V14", "V15", "V16", "V17", "V18", "V19", "V20",
|
13 |
+
"V21", "V22", "V23", "V24", "V25", "V26", "V27", "V28", "Amount"]
|
14 |
+
|
15 |
+
st.title('Fraud Detector')
|
16 |
+
for i in columns:
|
17 |
+
i = st.number_input("Please input the "+i+" value here.")
|
18 |
+
submit = st.button('Calculate')
|
19 |
+
|
20 |
+
input = [[V1, V2, V3, V4, V5, V6, V7, V8, V9, V10,
|
21 |
+
V11, V12, V13, V14, V15, V16, V17, V18, V19, V20,
|
22 |
+
V21, V22, V23, V24, V25, V26, V27, V28, Amount]]
|
23 |
+
|
24 |
+
input_df = pd.DataFrame(input, columns=columns)
|
25 |
+
|
26 |
+
prediction = classifier.predict(input_df)
|
27 |
+
|
28 |
+
|
29 |
+
if prediction == 1:
|
30 |
+
st.write("The transaction is fraudulant.")
|
31 |
+
|
32 |
+
else:
|
33 |
+
st.write("The transaction is normal.")
|
34 |
+
|
35 |
+
main()
|