added coloured evaluation buttons
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import streamlit as st
|
|
| 2 |
import pandas as pd
|
| 3 |
import logging
|
| 4 |
from deeploy import Client
|
|
|
|
| 5 |
from utils import get_request_body, get_fake_certainty, get_model_url, get_random_suspicious_transaction
|
| 6 |
from utils import get_explainability_texts, get_explainability_values
|
| 7 |
from utils import COL_NAMES, feature_texts
|
|
@@ -11,6 +12,9 @@ logging.basicConfig(level=logging.INFO)
|
|
| 11 |
|
| 12 |
st.set_page_config(layout="wide")
|
| 13 |
|
|
|
|
|
|
|
|
|
|
| 14 |
data = pd.read_pickle("data/preprocessed_data.pkl")
|
| 15 |
# data = data.drop('isFraud', axis=1)
|
| 16 |
|
|
@@ -60,8 +64,6 @@ with st.sidebar:
|
|
| 60 |
|
| 61 |
if "predict_button" not in st.session_state:
|
| 62 |
st.session_state.predict_button = False
|
| 63 |
-
st.title("Money Laundering System")
|
| 64 |
-
st.divider()
|
| 65 |
st.info(
|
| 66 |
"Fill in left hand side and click on button to observe a potential fraudulent transaction"
|
| 67 |
)
|
|
@@ -81,6 +83,7 @@ if st.session_state.predict_button:
|
|
| 81 |
|
| 82 |
create_data_input_table(datapoint_pd, COL_NAMES)
|
| 83 |
with col2:
|
|
|
|
| 84 |
certainty = get_fake_certainty()
|
| 85 |
st.metric(label='#### Model Certainty', value=certainty)
|
| 86 |
|
|
@@ -88,30 +91,32 @@ if st.session_state.predict_button:
|
|
| 88 |
explainability_values = get_explainability_values(sorted_indices, datapoint_pd)
|
| 89 |
create_table(explainability_texts, explainability_values, 'Important Suspicious Variables: ')
|
| 90 |
|
| 91 |
-
|
| 92 |
-
st.
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
st.session_state.
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
#
|
| 111 |
-
#
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
| 115 |
|
| 116 |
success = False
|
| 117 |
if st.session_state.eval_selected:
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import logging
|
| 4 |
from deeploy import Client
|
| 5 |
+
from streamlit_extras.stylable_container import stylable_container
|
| 6 |
from utils import get_request_body, get_fake_certainty, get_model_url, get_random_suspicious_transaction
|
| 7 |
from utils import get_explainability_texts, get_explainability_values
|
| 8 |
from utils import COL_NAMES, feature_texts
|
|
|
|
| 12 |
|
| 13 |
st.set_page_config(layout="wide")
|
| 14 |
|
| 15 |
+
st.title("Money Laundering System")
|
| 16 |
+
st.divider()
|
| 17 |
+
|
| 18 |
data = pd.read_pickle("data/preprocessed_data.pkl")
|
| 19 |
# data = data.drop('isFraud', axis=1)
|
| 20 |
|
|
|
|
| 64 |
|
| 65 |
if "predict_button" not in st.session_state:
|
| 66 |
st.session_state.predict_button = False
|
|
|
|
|
|
|
| 67 |
st.info(
|
| 68 |
"Fill in left hand side and click on button to observe a potential fraudulent transaction"
|
| 69 |
)
|
|
|
|
| 83 |
|
| 84 |
create_data_input_table(datapoint_pd, COL_NAMES)
|
| 85 |
with col2:
|
| 86 |
+
st.subheader('Prediction Explanation: ')
|
| 87 |
certainty = get_fake_certainty()
|
| 88 |
st.metric(label='#### Model Certainty', value=certainty)
|
| 89 |
|
|
|
|
| 91 |
explainability_values = get_explainability_values(sorted_indices, datapoint_pd)
|
| 92 |
create_table(explainability_texts, explainability_values, 'Important Suspicious Variables: ')
|
| 93 |
|
| 94 |
+
st.subheader("")
|
| 95 |
+
# st.markdown("<h2 style='text-align: center; white: red;'>Evaluation</h2>", unsafe_allow_html=True)
|
| 96 |
|
| 97 |
+
col3, col4 = st.columns(2)
|
| 98 |
+
|
| 99 |
+
with col3:
|
| 100 |
+
st.button("Send to FIU", key="yes_button", use_container_width=True)
|
| 101 |
+
ChangeButtonColour("Send to FIU", '#FFFFFF', "#DD360C")
|
| 102 |
+
if 'eval_selected' not in st.session_state:
|
| 103 |
+
st.session_state['eval_selected'] = False
|
| 104 |
+
# if yes_button:
|
| 105 |
+
# st.session_state.eval_selected = True
|
| 106 |
+
# st.session_state.evaluation_input = {
|
| 107 |
+
# "result": 0 # Agree with the prediction
|
| 108 |
+
# }
|
| 109 |
+
|
| 110 |
+
with col4:
|
| 111 |
+
st.button("Not money laundering", key="no_button", use_container_width=True)
|
| 112 |
+
ChangeButtonColour("Not money laundering", '#FFFFFF', "#46B071")
|
| 113 |
+
# if no_button:
|
| 114 |
+
# st.session_state.eval_selected = True
|
| 115 |
+
# desired_output = not predictions[0]
|
| 116 |
+
# st.session_state.evaluation_input = {
|
| 117 |
+
# "result": 1, # Disagree with the prediction
|
| 118 |
+
# "value": {"predictions": [desired_output]},
|
| 119 |
+
# }
|
| 120 |
|
| 121 |
success = False
|
| 122 |
if st.session_state.eval_selected:
|