got rid of error setting session state
Browse files
app.py
CHANGED
@@ -5,13 +5,13 @@ 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, send_evaluation, get_comment_explanation
|
7 |
from utils import COL_NAMES, feature_texts
|
8 |
-
from utils import create_data_input_table, create_table, ChangeButtonColour
|
9 |
|
10 |
logging.basicConfig(level=logging.INFO)
|
11 |
|
12 |
st.set_page_config(layout="wide")
|
13 |
|
14 |
-
st.title("
|
15 |
st.divider()
|
16 |
|
17 |
data = pd.read_pickle("data/preprocessed_data.pkl")
|
@@ -27,7 +27,6 @@ if "disabled" not in st.session_state:
|
|
27 |
st.session_state.disabled = False
|
28 |
|
29 |
def disabled():
|
30 |
-
# st.session_state.predict_button_clicked = True
|
31 |
st.session_state.disabled = True
|
32 |
|
33 |
def rerun():
|
@@ -37,9 +36,6 @@ def rerun():
|
|
37 |
def submitted_disabled():
|
38 |
st.session_state.submitted_disabled = True
|
39 |
|
40 |
-
if 'predict_button' not in st.session_state:
|
41 |
-
st.session_state.predict_button = False
|
42 |
-
|
43 |
st.markdown("""
|
44 |
<style>
|
45 |
[data-testid=stSidebar] {
|
@@ -60,8 +56,8 @@ with st.sidebar:
|
|
60 |
"Please enter Deeploy API token."
|
61 |
)
|
62 |
else:
|
63 |
-
st.button("Get suspicious transaction", key="predict_button", help="Click to get a suspicious transaction", use_container_width=True,
|
64 |
-
) #on_click=lambda: st.experimental_rerun()
|
65 |
ChangeButtonColour("Get suspicious transaction", '#FFFFFF', "#00052D")#'#FFFFFF', "#00052D"
|
66 |
|
67 |
|
@@ -73,11 +69,12 @@ with st.sidebar:
|
|
73 |
}
|
74 |
client = Client(**client_options)
|
75 |
|
|
|
|
|
|
|
76 |
if st.session_state.predict_button: # and not st.session_state.predict_button_clicked
|
77 |
st.session_state.predict_button_clicked = True
|
78 |
|
79 |
-
# if 'explanation' not in st.session_state:
|
80 |
-
# st.session_state.explanation = ""
|
81 |
if 'got_explanation' not in st.session_state:
|
82 |
st.session_state.got_explanation = False
|
83 |
|
@@ -123,14 +120,18 @@ if st.session_state.got_explanation:
|
|
123 |
create_data_input_table(datapoint_pd, COL_NAMES)
|
124 |
|
125 |
with col2:
|
126 |
-
st.subheader('
|
127 |
-
# st.
|
128 |
-
st.
|
129 |
-
|
|
|
|
|
|
|
130 |
|
131 |
explainability_texts, sorted_indices = get_explainability_texts(shap_values, feature_texts)
|
|
|
132 |
explainability_values = get_explainability_values(sorted_indices, datapoint_pd)
|
133 |
-
create_table(explainability_texts, explainability_values, 'Important Suspicious
|
134 |
|
135 |
st.subheader("")
|
136 |
# st.markdown("<h2 style='text-align: center; white: red;'>Evaluation</h2>", unsafe_allow_html=True)
|
@@ -143,7 +144,7 @@ if st.session_state.got_explanation:
|
|
143 |
with col3:
|
144 |
eval1 = st.empty()
|
145 |
eval1.button("Send to FIU", key="yes_button", use_container_width=True, disabled=st.session_state.submitted_disabled)
|
146 |
-
ChangeButtonColour("Send to FIU", '#FFFFFF', "#DD360C"
|
147 |
st.session_state.yes_button_clicked = False
|
148 |
|
149 |
if st.session_state.yes_button:
|
@@ -155,7 +156,7 @@ if st.session_state.got_explanation:
|
|
155 |
with col4:
|
156 |
eval2 = st.empty()
|
157 |
eval2.button("Not money laundering", key="no_button", use_container_width=True, disabled=st.session_state.submitted_disabled)
|
158 |
-
ChangeButtonColour("Not money laundering", '#FFFFFF', "#46B071"
|
159 |
st.session_state.no_button_clicked = False
|
160 |
|
161 |
|
@@ -193,6 +194,6 @@ if st.session_state.got_explanation:
|
|
193 |
eval1.empty()
|
194 |
eval2.empty()
|
195 |
eval3.empty()
|
196 |
-
st.
|
197 |
st.button("Next", key='next', use_container_width=True, on_click=rerun)
|
198 |
-
ChangeButtonColour("Next", '#FFFFFF', "#F9B917"
|
|
|
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, send_evaluation, get_comment_explanation
|
7 |
from utils import COL_NAMES, feature_texts
|
8 |
+
from utils import create_data_input_table, create_table, ChangeButtonColour, get_weights
|
9 |
|
10 |
logging.basicConfig(level=logging.INFO)
|
11 |
|
12 |
st.set_page_config(layout="wide")
|
13 |
|
14 |
+
st.title("Smart AML:tm:")
|
15 |
st.divider()
|
16 |
|
17 |
data = pd.read_pickle("data/preprocessed_data.pkl")
|
|
|
27 |
st.session_state.disabled = False
|
28 |
|
29 |
def disabled():
|
|
|
30 |
st.session_state.disabled = True
|
31 |
|
32 |
def rerun():
|
|
|
36 |
def submitted_disabled():
|
37 |
st.session_state.submitted_disabled = True
|
38 |
|
|
|
|
|
|
|
39 |
st.markdown("""
|
40 |
<style>
|
41 |
[data-testid=stSidebar] {
|
|
|
56 |
"Please enter Deeploy API token."
|
57 |
)
|
58 |
else:
|
59 |
+
st.button("Get suspicious transaction", key="predict_button", help="Click to get a suspicious transaction", use_container_width=True, on_click=disabled, disabled=st.session_state.disabled
|
60 |
+
) #on_click=lambda: st.experimental_rerun()
|
61 |
ChangeButtonColour("Get suspicious transaction", '#FFFFFF', "#00052D")#'#FFFFFF', "#00052D"
|
62 |
|
63 |
|
|
|
69 |
}
|
70 |
client = Client(**client_options)
|
71 |
|
72 |
+
if 'predict_button' not in st.session_state:
|
73 |
+
st.session_state.predict_button = False
|
74 |
+
|
75 |
if st.session_state.predict_button: # and not st.session_state.predict_button_clicked
|
76 |
st.session_state.predict_button_clicked = True
|
77 |
|
|
|
|
|
78 |
if 'got_explanation' not in st.session_state:
|
79 |
st.session_state.got_explanation = False
|
80 |
|
|
|
120 |
create_data_input_table(datapoint_pd, COL_NAMES)
|
121 |
|
122 |
with col2:
|
123 |
+
st.subheader('AML Model Hit')
|
124 |
+
# st.success(f'{certainty}')
|
125 |
+
# st.metric(label='Model Certainty', value=certainty)
|
126 |
+
# style_metric_cards(border_left_color='#00052D', box_shadow=False)
|
127 |
+
# # st.markdown('#### Model Certainty')
|
128 |
+
st.metric(label='Model Certainty', value=certainty)
|
129 |
+
|
130 |
|
131 |
explainability_texts, sorted_indices = get_explainability_texts(shap_values, feature_texts)
|
132 |
+
weights = get_weights(shap_values, sorted_indices)
|
133 |
explainability_values = get_explainability_values(sorted_indices, datapoint_pd)
|
134 |
+
create_table(explainability_texts, explainability_values, weights, 'Important Suspicious Factors')
|
135 |
|
136 |
st.subheader("")
|
137 |
# st.markdown("<h2 style='text-align: center; white: red;'>Evaluation</h2>", unsafe_allow_html=True)
|
|
|
144 |
with col3:
|
145 |
eval1 = st.empty()
|
146 |
eval1.button("Send to FIU", key="yes_button", use_container_width=True, disabled=st.session_state.submitted_disabled)
|
147 |
+
ChangeButtonColour("Send to FIU", '#FFFFFF', '#4C506C') #'#FFFFFF', "#DD360C"
|
148 |
st.session_state.yes_button_clicked = False
|
149 |
|
150 |
if st.session_state.yes_button:
|
|
|
156 |
with col4:
|
157 |
eval2 = st.empty()
|
158 |
eval2.button("Not money laundering", key="no_button", use_container_width=True, disabled=st.session_state.submitted_disabled)
|
159 |
+
ChangeButtonColour("Not money laundering", '#FFFFFF', '#4C506C') # '#FFFFFF', "#46B071", '#FFFFFF', "#666666"
|
160 |
st.session_state.no_button_clicked = False
|
161 |
|
162 |
|
|
|
194 |
eval1.empty()
|
195 |
eval2.empty()
|
196 |
eval3.empty()
|
197 |
+
st.warning("Feedback submitted successfully")
|
198 |
st.button("Next", key='next', use_container_width=True, on_click=rerun)
|
199 |
+
ChangeButtonColour("Next", '#FFFFFF', "#00052D") #'#FFFFFF', #F9B917" "#DD360C #457EA4
|