Duy-Anh Dang commited on
Commit
eca4634
·
1 Parent(s): 82d1fcd

empty.container

Browse files
Files changed (1) hide show
  1. app.py +40 -39
app.py CHANGED
@@ -210,42 +210,42 @@ with st.expander('Adjust your tone intensities for your preference: '):
210
 
211
  Loxz_recom_box = st.checkbox('Select Loxz Recommended Tones for Optimal Output')
212
 
213
- if st.button('Generate Predictions'):
214
- start_time = time.time()
215
- if input_text == "":
216
- st.error('Please enter a sentence!')
217
- else:
218
- placeholder = st.empty()
219
- placeholder.text('Loading Data...')
220
-
221
- # Starting predictions
222
- bucket='emailcampaignmodeldata'
223
- # file_key = 'fullEmailBody/fullemailtextbody_labeled_3rates_8tones_20220524.csv'
224
-
225
- # email_data = utils.get_files_from_aws(bucket,file_key)
226
- tone_key = 'ModelSADataSets/Tone_and_target.csv'
227
- tone_data = FunctionsModelSA_V1.load_data()
228
- test_predictions,tones = FunctionsModelSA_V1.convert_text_to_tone(input_text)
229
-
230
- # st.dataframe(test_predictions)
231
- # st.dataframe(tones)
232
- campaign_val='campaign_type_'+ campaign
233
- industry_val='industry_'+ industry
234
- pred,lower,upper,model = FunctionsModelSA_V1.prediction(tones,campaign_val,industry_val,target)
235
- worst_target,best_target,best_target_tones = FunctionsModelSA_V1.find_max_cat(tone_data,target,industry_val,campaign_val)
236
- #best_target, best_target_tones
237
- #FunctionsModelSA_V1.plot_CI(pred,lower,upper)
238
- st.write('The Predicted Value is ' + str(pred))
239
- fig1 = go.Figure(go.Bar(
240
- name = 'Tone Levels',
241
- x=[joyful_tone_value, confident_tone_value, urgent_tone_value, friendly_tone_value, optimistic_tone_value, analytical_tone_value, casual_tone_value],
242
- y=['Joyful', 'Confident', 'Urgent', 'Friendly', 'Optimistic', 'Analytical', 'Casual'],
243
- orientation='h')
244
- )
245
- st.plotly_chart(fig1, use_container_width=True)
246
-
247
- #if((best_target!=0) and (pred<best_target)):
248
- with st.empty():
249
  if Loxz_recom_box == True:
250
  recommended_changes=(best_target_tones)
251
  change=best_target-pred
@@ -275,7 +275,8 @@ if st.button('Generate Predictions'):
275
  fig2.update_layout(title_text=f'The following Changes will yield a {out} increase in {target}')
276
  st.plotly_chart(fig2, use_container_width=True)
277
  #FunctionsModelSA_V1.corrections(best_target_tones,test_predictions))
278
-
279
- placeholder.empty()
 
 
280
 
281
- WHITE_SPACE(10)
 
210
 
211
  Loxz_recom_box = st.checkbox('Select Loxz Recommended Tones for Optimal Output')
212
 
213
+ with st.empty().container():
214
+ if st.button('Generate Predictions'):
215
+ start_time = time.time()
216
+ if input_text == "":
217
+ st.error('Please enter a sentence!')
218
+ else:
219
+ placeholder = st.empty()
220
+ placeholder.text('Loading Data...')
221
+
222
+ # Starting predictions
223
+ bucket='emailcampaignmodeldata'
224
+ # file_key = 'fullEmailBody/fullemailtextbody_labeled_3rates_8tones_20220524.csv'
225
+
226
+ # email_data = utils.get_files_from_aws(bucket,file_key)
227
+ tone_key = 'ModelSADataSets/Tone_and_target.csv'
228
+ tone_data = FunctionsModelSA_V1.load_data()
229
+ test_predictions,tones = FunctionsModelSA_V1.convert_text_to_tone(input_text)
230
+
231
+ # st.dataframe(test_predictions)
232
+ # st.dataframe(tones)
233
+ campaign_val='campaign_type_'+ campaign
234
+ industry_val='industry_'+ industry
235
+ pred,lower,upper,model = FunctionsModelSA_V1.prediction(tones,campaign_val,industry_val,target)
236
+ worst_target,best_target,best_target_tones = FunctionsModelSA_V1.find_max_cat(tone_data,target,industry_val,campaign_val)
237
+ #best_target, best_target_tones
238
+ #FunctionsModelSA_V1.plot_CI(pred,lower,upper)
239
+ st.write('The Predicted Value is ' + str(pred))
240
+ fig1 = go.Figure(go.Bar(
241
+ name = 'Tone Levels',
242
+ x=[joyful_tone_value, confident_tone_value, urgent_tone_value, friendly_tone_value, optimistic_tone_value, analytical_tone_value, casual_tone_value],
243
+ y=['Joyful', 'Confident', 'Urgent', 'Friendly', 'Optimistic', 'Analytical', 'Casual'],
244
+ orientation='h')
245
+ )
246
+ st.plotly_chart(fig1, use_container_width=True)
247
+
248
+ #if((best_target!=0) and (pred<best_target)):
249
  if Loxz_recom_box == True:
250
  recommended_changes=(best_target_tones)
251
  change=best_target-pred
 
275
  fig2.update_layout(title_text=f'The following Changes will yield a {out} increase in {target}')
276
  st.plotly_chart(fig2, use_container_width=True)
277
  #FunctionsModelSA_V1.corrections(best_target_tones,test_predictions))
278
+
279
+ placeholder.empty()
280
+
281
+ WHITE_SPACE(10)
282