def main(): st.title("Image to LaTeX") with st.form(key="imputs"): st.markdown("## Upload an Image") image = st.file_uploader("", type=["jpg", "png"]) st.form_submit_button(label="Upload") with st.form(key="outputs"): st.markdown("## Convert to LaTeX") st.text("Uploaded image:") if image is not None: st.image(image) inference_button = st.form_submit_button(label="Infer") if inference_button and image is not None: with st.spinner("Wait for it..."): b64_image = base64.b64encode(image.read()) response = requests.post( API_PREDICT_URL, json={"image": f"data:image/png;base64,{b64_image.decode()}"}) if response.status_code == 200: st.markdown("**Inferred LaTex:**") st.code(response.json()["pred"], language="latex") st.markdown("**Render Inferred LaTeX:**") st.latex(response.json()["pred"]) else: st.error("An error occurred in the model server.")
def main(): st.title("Streamlit Forms & Salary Calculator") menu = ["Home","About"] choice = st.sidebar.selectbox("Menu",menu) if choice == "Home": st.subheader("Forms Tutorial") # Salary Calculator # Combine forms + columns with st.form(key='salaryform'): col1,col2,col3 = st.beta_columns([3,2,1]) with col1: amount = st.number_input("Hourly Rate in $") with col2: hour_per_week = st.number_input("Hours Per Week",1,120) with col3: st.text("Salary") submit_salary = st.form_submit_button(label='Calculate') if submit_salary: with st.beta_expander("Results"): daily = [amount * 8] weekly = [amount * hour_per_week] df = pd.DataFrame({'hourly':amount,'daily':daily,'weekly':weekly}) st.dataframe(df.T) # Method 1: Context Manager Approach (with) with st.form(key='form1'): firstname = st.text_input("Firstname") lastname = st.text_input("lastname") dob = st.date_input("Date of Birth") # Important submit_button = st.form_submit_button(label='SignUp') # Results Can be either form or outside if submit_button: st.success("Hello {} you ve created an account".format(firstname)) # Method 2: form2 = st.form(key='form2') username = form2.text_input("Username") jobtype = form2.selectbox("Job",["Dev","Data Scientist","Doctor"]) submit_button2 = form2.form_submit_button("Login") if submit_button2: st.write(username.upper()) else: st.subheader("About")
def test_multiple_forms_same_key(self): """Multiple forms with the same key are not allowed.""" with self.assertRaises(StreamlitAPIException) as ctx: st.form(key="foo") st.form(key="foo") self.assertIn("There are multiple identical forms with `key='foo'`", str(ctx.exception))
def test_form_in_form(self): """Test that forms cannot be nested in other forms.""" with self.assertRaises(StreamlitAPIException) as ctx: with st.form("foo"): with st.form("bar"): pass self.assertEqual(str(ctx.exception), "Forms cannot be nested in other forms.")
def test_multiple_forms_same_labels_different_keys(self): """Multiple forms with different keys are allowed.""" try: st.form(key="foo") st.form(key="bar") except Exception: self.fail("Forms with same labels and different keys failed to create.")
def main(): menu = ["Enter Details", "Search"] choice = st.sidebar.selectbox("Menu", menu) if choice == "Enter Details": st.subheader("Enter Details") with st.form(key='my_form1'): col1, col2 = st.columns(2) dob = col1.date_input('Enter DOB') First_name = col1.text_input("First Name", ) Last_name = col1.text_input("Last Name", ) col1.write('Select Skill') option_1 = col1.checkbox('Java') option_2 = col1.checkbox('Shell script') option_3 = col1.checkbox('Python') option_4 = col1.checkbox('SQL') submit_button = st.form_submit_button(label='Submit') if submit_button: update_df['dob'] = [dob] update_df['First_name'] = [First_name.strip()] update_df['Last_name'] = [Last_name.strip()] update_df['Java'] = [option_1] update_df['Shell Script'] = [option_2] update_df['Python'] = [option_3] update_df['SQL'] = [option_4] sh = gc.open('prototype') wks = sh[0] df = wks.get_as_df() df = df.append(update_df) wks.set_dataframe(df, (1, 1)) elif choice == "Search": st.subheader("Search") with st.form(key='my_form2'): col1, col2 = st.columns(2) First_name = col1.text_input("First Name", ) Last_name = col1.text_input("Last Name", ) submit_button = st.form_submit_button(label='Submit') if submit_button: sh = gc.open('prototype') wks = sh[0] df = wks.get_as_df() if (First_name != "") and (Last_name != ""): filtered_df = df[ (df['First_name'].str.strip() == (First_name.strip())) & (df['Last_name'].str.strip() == Last_name.strip())] if (Last_name) == "": filtered_df = df[(df['First_name'].str.strip() == ( First_name.strip()))] if (First_name) == "": filtered_df = df[(df['Last_name'].str.strip() == ( Last_name.strip()))] st.write(filtered_df.reset_index(drop=True))
def test_implicit_form_parent(self): """Within a `with form` statement, any `st.foo` element becomes part of that form.""" with st.form("form"): st.checkbox("widget") self.assertEqual("form", self._get_last_checkbox_form_id()) # The sidebar, and any other DG parent created outside # the form, does not create children inside the form. with st.form("form2"): st.sidebar.checkbox("widget2") self.assertEqual(NO_FORM_ID, self._get_last_checkbox_form_id())
def main(): st.title("Lyrica") def searchlyrics(): song = lyrics(Artist_name, Song_name) for words in song: return (words) def parse_lyrics(): profane_words = "4r5e5h1t,f**k,bustin\',busting,f****d,5hit,a55,anal,anus,ar5e,arrse,arse,ass,ass-f****r,asses,assfucker,assfukka,asshole,assholes,asswhole,a_s_s,b!tch,b00bs,b17ch,b1tch,ballbag,balls,ballsack,bastard,beastial,beastiality,bellend,bestial,bestiality,bi+ch,biatch,bitch,bitcher,bitchers,bitches,bitchin,bitching,bloody,blow job,b*****b,blowjobs,boiolas,bollock,bollok,boner,boob,boobs,booobs,boooobs,booooobs,booooooobs,breasts,buceta,bugger,bum,bunny f****r,butt,butthole,buttmuch,b******g,c0ck,c0cksucker,carpet muncher,cawk,chinkcipa,cl1t,c**t,clitoris,clits,cnut,c**k,c**k-sucker,cockface,cockhead,cockmunch,cockmuncher,cocks,cocksuck, cocksucked, c********r,cocksucking,cocksucks,cocksuka,cocksukka,c*k,cokmuncher,coksucka,coon,cox,crap,cum,cummer,cumming,cums,cumshot,cunilingus,cunillingus,cunnilingus,c**t,cuntlick, cuntlicker, cuntlicking, cunts,cyalis,cyberfuc,cyberfuck, cyberfucked, cyberfucker,cyberfuckerscyberfucking,d1ck,damn,dick,dickhead,d***o,dildos,dink,dinks,dirsa,dlck,dog-f****r,doggin,dogging,donkeyribber,doosh,duche,dyke,e*******e,ejaculated,ejaculates,ejaculating, ejaculatings,e*********n,ejakulate,f u c k,f u c k e r,f4nny,f*g,fagging,faggitt,f****t,faggs,fagot,fagots,fags,fanny,fannyflaps,fannyfucker,fanyy,fatass,fcuk,fcuker,fcuking,feck,fecker,f******g,f*****e,f******o,fingerfuck, fingerfucked, fingerfucker,fingerfuckers,fingerfucking,fingerfucks,fistfuck,fistfucked, fistfucker,fistfuckers, fistfucking, fistfuckings, fistfucks, flangefook,fookefuck,f***a,f****d,f****r,fuckers,fuckhead,fuckheads,f****n,f*****g,f******s,fuckingshitmotherfucker,f****e, f***s,fuckwhit,f*****t,fudge packer,f*********r,fuk,fukerfukker,fukkin,fuks,fukwhit,fukwit,f*x,fux0r,f_u_c_k,g******g,gangbanged, gangbangs, gaylord,gaysex,g****e,God,god-dam,god-damned,goddamn,goddamned,hardcoresex, hell,heshe,hoar,hoare,hoer,h**o,hore,horniest,horny,hotsex,jack-off, jackoff,jap,jerk-off, jism,j*z,jizm, j**z,kawk,knob,knobeadknobed,k*****d,knobhead,knobjocky,knobjokey,kock,kondum,kondums,kum,kummer,kumming,kums,kunilingus,l3i+ch,l3itch,labia,lmfao,lust,lusting,m0f0,m0fo,m45terbate,ma5terb8,ma5terbate,m*******t,master-bate,masterb8,masterbat*,masterbat3,masterbate,masterbation,masterbations,m********e,mo-fo,mof0,mofo,mothafuck,m********a,mothafuckas,mothafuckaz,mothafucked, mothafucker,mothafuckers,mothafuckin,mothafucking, mothafuckings,mothafucks,mother f****r,motherfuck,motherfucked,m**********r,motherfuckers,motherfuckin,motherfucking,motherfuckings,motherfuckka,motherfucks,muff,mutha,muthafecker,muthafuckker,muther,mutherfucker,n1gga,n1gger,nazi,nigg3r,nigg4h,n***a,niggah,n****s,niggaz,nigger,niggers, nob,nob jokey,nobhead,nobjocky,nobjokey,numbnuts,nutsack,orgasim,orgasims, o****m,o*****s, p0rn,pawn,pecker,penis,penisfucker,phonesex,phuck,phuk,phuked,phuking,phukked,phukking,phuks,phuq,pigfucker,pimpis,piss,pissed,pisser,pissers,pisses,pissflaps,pissin, pissing,pissoff,poop,p**n,porno,pornography,pornos,prick,pricks, pron,pube,p***e,pussi,pussies,pussy,pussys, rectum,retard,rimjaw,rimming,s hit,s.o.b.,s****t,schlong,screwing,scroat,scrote,scrotum,s***n,sex,sh!+,sh!t,sh1tshag,shagger,shaggin,shagging,shemale,shi+,shit,shitdick,s***e,shited,shitey,shitfuck,shitfull,s******d,shiting,shitings,shits,s*****d,shitter,shitters, s******g,s*******s,shitty,skank,s**t,s***s,s****a,smut,snatch,son-of-a-bitch,spac,spunk,s_h_i_t,t1tt1e5,t1tties,teets,teez,testical,testicle,tit,titfuck,t**s,titt,tittie5,tittiefucker,titties,tittyfuck,tittywank,titwank,tosser,turd,tw4t,twat,twathead,twatty,twunt,twunter,v14gra,v1gra,v****a,viagra,vulva,w00se,wang,wank,wanker,wanky,whoar,w***e,willies,willy,xrated,xxx" profane = profane_words.replace(",", " ") profane = profane.split(" ") profane = unique.union(set(profane)) stpwrds = stopwords.words("english") tokens = word_tokenize(searchlyrics()) removing_stopwords = [ words for words in tokens if not words in stpwrds ] new_stopwords = stopwords.words("english") new_stopwords = new_stopwords.extend(profane) removing = [word for word in removing_stopwords if word in profane] return removing menu = ["Home", "About"] choice = st.sidebar.selectbox("Menu", menu) if choice == "Home": st.subheader("Forms Tutorial") with st.form(key="searcher"): Artist_name = st.text_input("Artist") Song_name = st.text_input("Song") Fetch = st.form_submit_button("Fetch Lyrics") if Fetch: with st.beta_expander("Lyrics"): st.write(searchlyrics()) st.success("Lyrics fetched successfully") with st.form(key="form1"): # Lyrics = st.text_area("Lyrics", height=300) lyrica = st.empty() Analyze = st.form_submit_button("Analyze") if Analyze: with st.beta_expander("Keywords"): st.write(parse_lyrics()) else: st.subheader("About")
def form(): with st.form("my_form"): st.write("Envie os seguintes dados abaixo") with col1: st.write(""" ## João da silva (aposentado/funcionario publico)""") with col2: date = st.date_input('Data de nascimento', datetime.date.today()) st.write("## Foto") uploaded_file_foto = st.file_uploader("Choose a file", key=1) st.write("## Audio") uploaded_file_audio = st.file_uploader("Choose a file", key=2) st.write("## Video") uploaded_file_video = st.file_uploader("Choose a file", key=3) # Every form must have a submit button. submitted = st.form_submit_button("Submit") if submitted: st.write("data", date) st.write(date) st.balloons() ## enviar para api de autenticação ## enciar para s3 e rodar sagemaker para validação ## usar ec2 para hosting st.write(" ")
def test_widget_created_directly_on_form_block(self): """Test that a widget can be created directly on a form block.""" form = st.form("form") form.checkbox("widget") self.assertEqual("form", self._get_last_checkbox_form_id())
def predict_page(self): st.write('## Simulator') st.write("""Predict the outcome or probability of survival by customizing the input data of individuals""") st.write('') model_list = os.listdir('../output') avail_algo = [re.search('(?<=model_).+(?=\.pkl)', m).group(0) for m in model_list] with st.form(key="predict_form"): # New Data col1, col2, col3 = st.columns(3) pclass = col1.radio("Passage Class", (1, 2, 3), format_func=lambda x: CLASS_NAME[x]) sex = col2.selectbox("Sex", ('male', 'female'), format_func=lambda x: x.title()) age = col3.number_input("Age", step = 5) new_data = pd.DataFrame({ 'Pclass': [pclass], 'Sex': [sex], 'Age': [age] }) # Prediction Options col4, col5 = st.columns([2, 1]) algorithm = col4.selectbox('Algorithm', avail_algo, format_func=lambda x: ALGO_NAME[x]) probs = col5.radio('Predict Probability?', (True, False), format_func=lambda x: 'Yes' if x else 'No') predict = st.form_submit_button(label = 'Predict') if predict: pred = self.predict(new_data, algorithm, probs) if probs: velocimeter_chart(pred[0]) else: outcome = 'SURVIVED' if pred == 1 else 'DIED' st.write(f""" The model predicted that this individual would have ### {outcome} in the Titanic tragic accident """)
def test_dg_and_element_inside_form(self): """Test that a widget belongs to a form if its DG was created inside it and then replaced.""" with st.form("form"): empty = st.empty() empty.checkbox("widget") self.assertEqual("form", self._get_last_checkbox_form_id())
def test_submit_button_inside_form(self): """Test that a submit button is allowed inside a form.""" with st.form("foo"): st.form_submit_button() last_delta = self.get_delta_from_queue() self.assertEqual("foo", last_delta.new_element.button.form_id)
def test_submit_button_called_directly_on_form_block(self): """Test that a submit button can be called directly on a form block.""" form = st.form("foo") form.form_submit_button() last_delta = self.get_delta_from_queue() self.assertEqual("foo", last_delta.new_element.button.form_id)
def test_dg_outside_form_but_element_inside(self): """Test that a widget doesn't belong to a form if its DG was created outside it.""" empty = st.empty() with st.form("form"): empty.checkbox("widget") first_delta = self.get_delta_from_queue(0) self.assertEqual(NO_FORM_ID, first_delta.new_element.checkbox.form_id)
def test_button_in_form(self): """Test that buttons are not allowed in forms.""" with self.assertRaises(StreamlitAPIException) as ctx: with st.form("foo"): st.button("foo") assert "`st.button()` can't be used in an `st.form()`" in str( ctx.exception)
def test_deep_implicit_form_parent(self): """Within a `with form` statement, any `st.foo` element becomes part of that form, regardless of how deeply nested the element is.""" with st.form("form"): cols1 = st.beta_columns(2) with cols1[0]: with st.beta_container(): st.checkbox("widget") self.assertEqual("form", self._get_last_checkbox_form_id()) # The sidebar, and any other DG parent created outside # the form, does not create children inside the form. with st.form("form2"): cols1 = st.beta_columns(2) with cols1[0]: with st.beta_container(): st.sidebar.checkbox("widget2") self.assertEqual(NO_FORM_ID, self._get_last_checkbox_form_id())
def main(): st.title("Titanic: Machine Learning from Disaster") df = load_data() target = "Survived" features = [c for c in df.columns.values if c != target] with st.beta_expander("About Titanic"): c1, c2 = st.beta_columns(2) description = read_markdown_file("pages/titanic.md") c1.markdown(f"{description}", unsafe_allow_html=True) c2.image("images/titanic.jpg") st.header("Data preview") st.caption(f"Shape of dataset : {df.shape[0]} rows, {df.shape[1]} columns") st.dataframe(df.describe()) cols_to_style = st.multiselect("Choose columns to apply BG gradient", features) st.dataframe( df.style.background_gradient(subset=cols_to_style, cmap="BuGn")) st.markdown("---") st.header("Plot distribution") col = st.selectbox("Choose a column to display", features) with_target = st.checkbox("Separate per target ?") chart = (alt.Chart(df).mark_bar().encode( alt.X(f"{col}:Q", bin=alt.Bin(maxbins=10)), alt.Y("count()"), tooltip=[col, "count()"], ).interactive()) if with_target: chart = chart.encode(color=f"{target}:N") st.altair_chart(chart, use_container_width=True) st.markdown("---") st.header("Correlation") fig, ax = plt.subplots() sns.heatmap(df.corr(), ax=ax) st.pyplot(fig) st.markdown("---") st.header("Classification") with st.form(key="classify"): c1, c2 = st.beta_columns(2) n_estimators = c1.number_input("Choose number of trees:", 1, 1000, 100) max_depth = c2.number_input("Max depth:", 1, 100, 5) button_pressed = st.form_submit_button(label="Train model") if button_pressed: with st.spinner("Training..."): clf, confusion_matrix, importance_plot, force_plot = train_rf( df, n_estimators, max_depth) st.balloons() st.pyplot(confusion_matrix) st.pyplot(importance_plot) st_shap(force_plot, 400)
def test_form_inside_columns(self): """Test that a form was successfully created inside a column.""" col, _ = st.beta_columns(2) with col: with st.form("form"): st.checkbox("widget") self.assertEqual("form", self._get_last_checkbox_form_id())
def web_visualisation(): submitted = False while not submitted: with st.form("my_form"): st.title("Are you likely to have heart disease?") age = st.slider("How old are you?", 0, 100) sex = st.radio("What is your gender?", ["Male", "Female"]) cp = st.radio("What is your chest pain type", [0, 1, 2, 3]) trtbps = st.slider("What is your resting blood pressure (Hg)?", 0, 200) chol = st.slider("What is your cholestrol level (mg /dl)?", 0, 700) fbs = st.radio("What is your fasting blood sugar (mg) ?", [0, 1]) restecg = st.slider( "What is resting electrocardiographic results?", 0, 2) thalachh = st.slider("What is your maximmum heart rate?", 0, 200) exng = st.radio("Does your exercise induce anigma?", ["No", "Yes"]) oldpeak = st.slider( "What is ST depression induced by exercise relative to rest?", 0.00, 7.00, step=0.05) slp = st.slider( "What is the slope of the peak exercise ST segment?", 0, 2) caa = st.slider( "What is number of major vessels (0-3) colored by flourosopy?", 0, 3) thall = st.radio( "3 = normal; 6 = fixed defect; 7 = reversable defect", [3, 6, 7]) submitted = st.form_submit_button("Submit") if sex == 'Female': sex = 0 sex = 1 if thall == 3: thall = 1 elif thall == 6: thall = 2 else: thall = 3 if exng == "No": exng = 0 else: exng = 1 heart_param = np.array([ age, sex, cp, trtbps, chol, fbs, restecg, thalachh, exng, oldpeak, slp, caa, thall ]) submitted = True return heart_param
def continuar(msg, state): with st.form(key='continue'): st.text(msg) state.uploaded_files.pop(0) state.opened_file = False state.checked_file = False state.processed_file = False state.selected_option = False state.appended_file = False st.form_submit_button(label='Continuar') st.stop()
def test_form_block_id(self): """Test that a form creates a block element with a correct id.""" # Calling `with` will invoke `__exit__` on `DeltaGenerator` with st.form(key="foo"): pass # Check that we create a form block element self.assertEqual(len(self.get_all_deltas_from_queue()), 1) form_proto = self.get_delta_from_queue(0).add_block self.assertIn("foo", form_proto.form_id)
def test_inside_form(self): """Test that form id is marshalled correctly inside of a form.""" with st.form("form"): st.radio("foo", ["bar", "baz"]) # 2 elements will be created: form block, widget self.assertEqual(len(self.get_all_deltas_from_queue()), 2) form_proto = self.get_delta_from_queue(0).add_block radio_proto = self.get_delta_from_queue(1).new_element.radio self.assertEqual(radio_proto.form_id, form_proto.form.form_id)
def test_inside_form(self): """Test that form id is marshalled correctly inside of a form.""" with st.form("form"): st.checkbox("foo") # 2 elements will be created: a block and a checkbox self.assertEqual(len(self.get_all_deltas_from_queue()), 2) form_proto = self.get_delta_from_queue(0).add_block.form checkbox_proto = self.get_delta_from_queue(1).new_element.checkbox self.assertEqual(checkbox_proto.form_id, form_proto.form_id)
def test_inside_form(self): """Test that form id is marshalled correctly inside of a form.""" with st.form("form"): st.color_picker("foo") # 2 elements will be created: form block, widget self.assertEqual(len(self.get_all_deltas_from_queue()), 2) form_proto = self.get_delta_from_queue(0).add_block color_picker_proto = self.get_delta_from_queue(1).new_element.color_picker self.assertEqual(color_picker_proto.form_id, form_proto.form_id)
def _create_sidebar(self) -> None: state = self._state devdf = gui_get_df('device', columns=['namespace']) if devdf.empty: st.error('Unable to retrieve any namespace info') st.stop() namespaces = [''] + sorted(devdf.namespace.unique().tolist()) if self._state.namespace: nsidx = namespaces.index(self._state.namespace) else: nsidx = 0 url = '&'.join([ f'{get_base_url()}?page=Help&session={get_session_id()}', 'help=yes', 'help_on=Path', ]) display_help_icon(url) with st.sidebar: with st.form(key='trace'): state.namespace = st.selectbox('Namespace', namespaces, key='path_namespace', index=nsidx) state.source = st.text_input('Source IP', key='path_source', value=state.source) state.dest = st.text_input('Dest IP', value=state.dest, key='path_dest') state.vrf = st.text_input('VRF', value=state.vrf, key='path_vrf') state.start_time = st.text_input('Start Time', value=state.start_time, key='path_start_time') state.end_time = st.text_input('End Time', value=state.end_time, key='path_end_time') _ = st.form_submit_button('Trace', on_click=self._sync_state) state.show_ifnames = st.checkbox('Show in/out interface names', value=state.show_ifnames, key='path_show_ifnames', on_change=self._sync_state) _ = st.button('Source <-> Dest', key='path_swap', on_click=self._sync_state)
def test_marshall_form(self): """Creating a form should result in the expected protobuf data.""" # Test with clear_on_submit=True with st.form(key="foo", clear_on_submit=True): pass self.assertEqual(len(self.get_all_deltas_from_queue()), 1) form_proto = self.get_delta_from_queue(0).add_block self.assertEqual("foo", form_proto.form.form_id) self.assertEqual(True, form_proto.form.clear_on_submit) self.clear_queue() # Test with clear_on_submit=False with st.form(key="bar", clear_on_submit=False): pass self.assertEqual(len(self.get_all_deltas_from_queue()), 1) form_proto = self.get_delta_from_queue(0).add_block self.assertEqual("bar", form_proto.form.form_id) self.assertEqual(False, form_proto.form.clear_on_submit)
def test_parent_created_outside_form(self): """If our parent was created outside a form, any children of that parent have no form, regardless of where they're created.""" no_form_col = st.beta_columns(2)[0] no_form_col.checkbox("widget1") self.assertEqual(NO_FORM_ID, self._get_last_checkbox_form_id()) with st.form("form"): no_form_col.checkbox("widget2") self.assertEqual(NO_FORM_ID, self._get_last_checkbox_form_id()) with no_form_col: st.checkbox("widget3") self.assertEqual(NO_FORM_ID, self._get_last_checkbox_form_id())
def main(): st.title("Emotion Classifier App") menu = ["Home", "Monitor", "About"] choice = st.sidebar.selectbox("Menu", menu) if choice == "Home": st.subheader("Home-Emotion In Text") with st.form(key='emotion_clf_form'): raw_text = st.text_area("Type Here") submit_text = st.form_submit_button(label='Submit') if submit_text: col1, col2 = st.beta_columns(2) # Apply Fxn Here prediction = predict_emotions(raw_text) probability = get_prediction_proba(raw_text) #add_prediction_details(raw_text,prediction,np.max(probability)) with col1: st.success("Original Text") st.write(raw_text) st.success("Prediction") emoji_icon = emotions_emoji_dict[prediction] st.write("{}:{}".format(prediction, emoji_icon)) st.write("Confidence:{}".format(np.max(probability))) with col2: st.success("Prediction Probability") # st.write(probability) proba_df = pd.DataFrame(probability, columns=pipe_lr.classes_) # st.write(proba_df.T) proba_df_clean = proba_df.T.reset_index() proba_df_clean.columns = ["emotions", "probability"] fig = alt.Chart(proba_df_clean).mark_bar().encode( x='emotions', y='probability', color='emotions') st.altair_chart(fig, use_container_width=True) elif choice == "Monitor": st.subheader("Monitor App") else: st.subheader("About")
def delete(st_obj): with st_obj: with st.form(key='delete_review'): st.subheader('Delete review from database') st.markdown('Copy and paste the ID of the review to be deleted') update_id = st.text_input('Enter review ID', key='delete') update_table = st.selectbox('Enter table to be deleted from',['movie-reviews', 'short-film-reviews']) st.info('This action is non-reversible. Once deleted, review cannot be recovered.') submit_delete = st.form_submit_button('Confirm deletion of selected review') if submit_delete: Database.deleteReview(update_table, update_id)