mtyrrell commited on
Commit
a295957
·
1 Parent(s): 252b0a0

Added new logic; bug fixes

Browse files
Files changed (2) hide show
  1. app.py +5 -5
  2. modules/utils.py +12 -2
app.py CHANGED
@@ -26,8 +26,7 @@ from modules.auth import validate_login
26
  from modules.utils import create_excel, clean_text, extract_predicted_labels, predict_category, process_data
27
 
28
  # Local
29
- # from dotenv import load_dotenv
30
- # load_dotenv()
31
 
32
 
33
  # Main app logic
@@ -80,7 +79,7 @@ def main():
80
  sens_options = {
81
  "Low": 4,
82
  "Medium": 5,
83
- "High": 7,
84
  }
85
 
86
  sens_input = st.sidebar.radio(label = 'Select the Sensitivity Level [OPTIONAL]',
@@ -90,7 +89,8 @@ def main():
90
  FNs at the lowest setting is approximately 6 percent, and \
91
  approaches 13 percent at the highest setting. \
92
  NOTE: changing this setting does not affect the raw data in the CSV output file (only the REVIEW/REJECT labels)',
93
- options = list(sens_options.keys()),
 
94
  horizontal = False)
95
 
96
  sens_level = sens_options[sens_input]
@@ -169,7 +169,7 @@ def main():
169
  st.rerun()
170
 
171
 
172
- # Comment out or remove the else block containing login form
173
  else:
174
  username = st.text_input("Username")
175
  password = st.text_input("Password", type="password")
 
26
  from modules.utils import create_excel, clean_text, extract_predicted_labels, predict_category, process_data
27
 
28
  # Local
29
+ /
 
30
 
31
 
32
  # Main app logic
 
79
  sens_options = {
80
  "Low": 4,
81
  "Medium": 5,
82
+ "High": 6,
83
  }
84
 
85
  sens_input = st.sidebar.radio(label = 'Select the Sensitivity Level [OPTIONAL]',
 
89
  FNs at the lowest setting is approximately 6 percent, and \
90
  approaches 13 percent at the highest setting. \
91
  NOTE: changing this setting does not affect the raw data in the CSV output file (only the REVIEW/REJECT labels)',
92
+ options = list(sens_options.keys()),
93
+ index = list(sens_options.keys()).index("High"),
94
  horizontal = False)
95
 
96
  sens_level = sens_options[sens_input]
 
169
  st.rerun()
170
 
171
 
172
+ # Comment out for testing
173
  else:
174
  username = st.text_input("Username")
175
  password = st.text_input("Password", type="password")
modules/utils.py CHANGED
@@ -215,6 +215,16 @@ def process_data(uploaded_file, sens_level):
215
  # Further data processing and actions
216
  sector_classes = ['Energy','Transport','Industries']
217
  df['pred_score'] = df.apply(lambda x: round((x['fin_lab2']*2 + x['scope_lab1']*2 + x['scope_lab2']*2 + x['tech_lab1'] + x['tech_lab3']+ x['lev_gt_0']+x['lev_maf_scale'])/10*10,0), axis=1)
218
- df['pred_action'] = df.apply(lambda x: 'REJECT' if (x['pred_score'] <4 or x['LANG'] != 'en-US' or x['ADAPMIT'] == 'Adaptation' or not ((x['SECTOR1'] in sector_classes) or (x['SECTOR2'] in sector_classes))) else 'REVIEW', axis=1)
 
 
 
 
 
 
 
 
 
 
 
219
 
220
- return df
 
215
  # Further data processing and actions
216
  sector_classes = ['Energy','Transport','Industries']
217
  df['pred_score'] = df.apply(lambda x: round((x['fin_lab2']*2 + x['scope_lab1']*2 + x['scope_lab2']*2 + x['tech_lab1'] + x['tech_lab3']+ x['lev_gt_0']+x['lev_maf_scale'])/10*10,0), axis=1)
218
+ # df['pred_action'] = df.apply(lambda x: 'REJECT' if (x['pred_score'] <4 or x['LANG'] != 'en-US' or x['ADAPMIT'] == 'Adaptation' or not ((x['SECTOR1'] in sector_classes) or (x['SECTOR2'] in sector_classes))) else 'REVIEW', axis=1)
219
+ df['pred_action'] = df.apply(lambda x:
220
+ 'INELIGIBLE' if (x['LANG'] != 'en-US' or
221
+ x['ADAPMIT'] == 'Adaptation' or
222
+ not any(sector in [x['SECTOR1'], x['SECTOR2']] for sector in sector_classes))
223
+ else 'REJECT' if x['pred_score'] <= sens_level
224
+ else 'PRE-ASSESSMENT' if sens_level+1 <= x['pred_score'] <= sens_level+2
225
+ else 'FULL-ASSESSMENT' if x['pred_score'] > sens_level+2
226
+ else 'ERROR', axis=1)
227
+
228
+ return df
229
+
230