def test_outside_form(self): """Test that form id is marshalled correctly outside of a form.""" st.color_picker("foo") proto = self.get_delta_from_queue().new_element.color_picker self.assertEqual(proto.form_id, "")
def test_just_label(self): """Test that it can be called with no value.""" st.color_picker("the label") c = self.get_delta_from_queue().new_element.color_picker self.assertEqual(c.label, "the label") self.assertEqual(c.default, "#000000")
def test_value_types(self, arg_value, proto_value): """Test that it supports different types of values.""" st.color_picker("the label", arg_value) c = self.get_delta_from_queue().new_element.color_picker self.assertEqual(c.label, "the label") self.assertEqual(c.default, proto_value)
def main(): """A Simple Streamlit App """ st.title("BioInformatics Web App") #activity = ['Intro','DNA','DotPlot',"About"] # choice = st.sidebar.selectbox("Select Activity",activity) # if choice == 'Intro': # st.subheader("Intro") # elif choice == "DNA Sequence": # st.subheader("DNA Sequence Analysis") #input sequence seq_input = st.text_input('Input Sequence') #check validity of sequence entered validateSeq(seq_input) details = st.radio("Functions",("Sequence Length", "Frequency of each Nucleotide", "Transcription of DNA", "Reverse Transcription", "Find Complementory Strand", "GC Content Percentage")) if details == "Sequence Length": st.write(len(seq_input)) elif details == "Frequency of each Nucleotide": st.subheader("Nucleotide Frequency") seq_input = Counter(seq_input) st.write(seq_input) adenine_color = st.color_picker("Adenine Color") thymine_color = st.color_picker("thymine Color") guanine_color = st.color_picker("Guanine Color") cytosil_color = st.color_picker("cytosil Color") if st.button("Plot Freq"): barlist = plt.bar(seq_input.keys(),seq_input.values()) barlist[2].set_color(adenine_color) barlist[3].set_color(thymine_color) barlist[1].set_color(guanine_color) barlist[0].set_color(cytosil_color) st.pyplot() elif details == "Transcription of DNA": st.write(transcription(seq_input)) elif details == "Reverse Transcription": st.write(reversetranscription(seq_input)) elif details == "Find Complementory Strand": st.text(f" DNA String + Complement + Reverse Complement: \n 5'{seq_input} 3' \n {''.join(['|' for c in range(len(seq_input))])} \n 3'{reverse_complement(seq_input)[::-1]} 5'[Complement] \n 5'{reverse_complement(seq_input)} 3'[Reverse Complement]") elif details == "GC Content Percentage": st.write(f" {gc_content(seq_input)}%")
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 main(): data = pd.read_csv("research-and-development-survey-2019-csv.csv") data_1 = pd.read_csv( "greenhouse-gas-emissions-by-region-industry-and-household-year-ended-2018-csv.csv" ) st.dataframe(data) st.table(data.iloc[0:10]) st.dataframe(data_1) st.table(data_1.iloc[0:10]) st.line_chart(data_1) st.json({'foo': 'bar', 'fu': 'ba'}) st.beta_container() st.beta_columns(4) col1, col2 = st.beta_columns(2) col1.subheader('Columnisation') st.beta_expander('Expander') with st.beta_expander('Expand'): st.write('Juicy deets') st.sidebar.write("# Noniot") a = st.sidebar.radio('R:', [1, 2]) st.button('Hit me') st.checkbox('Check me out') st.radio('Radio', [1, 2, 3]) st.selectbox('Select', [1, 2, 3]) st.multiselect('Multiselect', [1, 2, 3]) st.slider('Slide me', min_value=0, max_value=10) st.select_slider('Slide to select', options=[1, '2']) st.text_input('Enter some text') st.number_input('Enter a number') st.text_area('Area for textual entry') st.date_input('Date input') st.time_input('Time entry') st.file_uploader('File uploader') st.color_picker('Pick a color') st.progress(90) st.spinner() with st.spinner(text='In progress'): time.sleep(5) st.success('Done') st.balloons() st.error('Error message') st.warning('Warning message') st.info('Info message') st.success('Success message') st.exception("e")
def __init__(self, image: np.ndarray, bboxes: np.ndarray): """[summary] Args: image (np.ndarray): shape(height, width, channels) bboxes (np.ndarray): shape(num_glimpses, num_boxes=20, 5) where the 5 numbers (xmin, ymin, xmax, ymax, confidence) """ st.markdown('### Top-attended bounding boxes') st.markdown( 'To answer the question, the system pays more attention to some regions of the image\ than others. The boxes on the image are colour-coded with the confidence of the system.' ) self.color_cols = st.beta_columns(4) with self.color_cols[0]: self.first = (st.color_picker('conf > 50%', '#48b5a3')) with self.color_cols[1]: self.second = (st.color_picker('25% < conf < 50%', '#6fb7d6')) with self.color_cols[2]: self.third = (st.color_picker('10% < conf < 25%', '#fca985')) with self.color_cols[3]: self.fourth = (st.color_picker('conf < 10%', '#f0e8cd')) st.markdown( 'However, we may end up with an incorrect answer if some critical regions are not attended to. Thus, the model makes two sets of predictions to avoid missing such important regions.' ) self.cols = st.beta_columns(bboxes.shape[0]) self.image = np.copy(image) self.bboxes = bboxes self.topk = st.slider( 'Drag the slider to change the number of objects (displayed in decreasing order of confidence)', min_value=1, max_value=10, value=3, step=1, format=None, key=None) self.plot_boxes()
def render(assay): with st.sidebar.beta_expander('Customizations'): interface.info('Rename the labels.<br>Merge by giving the same name.') lab_map = {} keep_labs = [] pal = assay.get_palette() lab_set = np.unique(assay.get_labels()) for lab in lab_set: col1, col2, col3 = st.beta_columns([1, 0.1, 0.07]) with col1: new_name = st.text_input(f'Give a new name to {lab}', lab) with col2: st.markdown(f"<p style='margin-bottom:34px'></p>", unsafe_allow_html=True) pal[lab] = st.color_picker('', pal[lab], key=f'colorpicker-{lab}') with col3: st.markdown(f"<p style='margin-bottom:42px'></p>", unsafe_allow_html=True) keep = st.checkbox('', True, key=f'keep-cells-{lab}-{lab_set}') if keep: keep_labs.append(lab) if new_name != lab: lab_map[lab] = new_name pal[new_name] = pal[lab] del pal[lab] if len(keep_labs) == 0: interface.error('At least one label must be selected.') return lab_map, pal, keep_labs
def main(): fname = st.text_input('이름을 입력하세요') st.title(fname) fname2 = st.text_input('이름을 입력하세요', max_chars=5) # 유저한테 입력 받을 껀데 5글자까지만 나오게해라 st.title(fname2) #text 해도됨 day01에서 했음 message = st.text_area('메세지를 입력하세요', height=3) # 문자를 3줄 까지 입력가능 st.write(message) number = st.number_input('숫자 입력', 1, 100) # 1부터 100까지 정수로 입력받을수 있음 st.write(number) number2 = st.number_input('숫자입력', 0.0, 20.0) # 0.0 부터 20.0 까지 # 아무것도 안쓰면 실수로 자동 st.write(number2) my_date = st.date_input('약속 날짜') # 날짜 선택 가능 st.write(my_date) my_time = st.time_input('시간 선택') # 시간 선택 가능 st.write(my_time) password = st.text_input('비밀번호 입력', type='password', max_chars=12) # 타입 파라미터 뭐있는지 확인해 st.write(password) # 비밀번호 입력할수있게 함 12 글자 까지만 color = st.color_picker('색을 선택하세요') # 색깔 선택하기 st.write(color)
def _display_y_axis_title_settings(self, y_axis_title_settings): # Customize y axis title y_axis_title = st.text_input("Y-Axis Title", "Default", max_chars=50) # Customize y axis title font size and add add value to y axis settings y_axis_title_font_size = st.slider("Y Axis Title Font Size", min_value=8, max_value=40, value=10, step=1) y_axis_title_settings["titleFontSize"] = y_axis_title_font_size # Customize y axis title color and add add value to y axis settings y_axis_title_color = st.color_picker("Y Axis Title Color") y_axis_title_settings["titleColor"] = y_axis_title_color y_axis_anchor = st.selectbox("Y Axis Title Position", ["Start", "Middle", "End"], index=1) y_axis_title_settings["titleAnchor"] = y_axis_anchor.lower() y_axis_title_padding = st.slider("Y Axis Title Padding", min_value=0, max_value=40, value=5, step=1) y_axis_title_settings["titlePadding"] = y_axis_title_padding return y_axis_title, y_axis_title_settings
def visualize_ner( pipe, # Nlu component_list text:str, ner_tags: Optional[List[str]] = None, show_label_select: bool = True, show_table: bool = False, title: Optional[str] = "Named Entities", sub_title: Optional[str] = "Recognize various `Named Entities (NER)` in text entered and filter them. You can select from over `100 languages` in the dropdown.", colors: Dict[str, str] = {}, show_color_selector: bool = False, set_wide_layout_CSS:bool=True, generate_code_sample:bool = False, key = "NLU_streamlit", model_select_position:str = 'side', show_model_select : bool = True, show_text_input:bool = True, show_infos:bool = True, show_logo:bool = True, ): StreamlitVizTracker.footer_displayed=False if set_wide_layout_CSS : _set_block_container_style() if show_logo :StreamlitVizTracker.show_logo() if show_model_select : model_selection = Discoverer.get_components('ner',include_pipes=True) model_selection.sort() if model_select_position == 'side':ner_model_2_viz = st.sidebar.selectbox("Select a NER model",model_selection,index=model_selection.index(pipe.nlu_ref.split(' ')[0])) else : ner_model_2_viz = st.selectbox("Select a NER model",model_selection,index=model_selection.index(pipe.nlu_ref.split(' ')[0])) pipe = pipe if pipe.nlu_ref == ner_model_2_viz else StreamlitUtilsOS.get_pipe(ner_model_2_viz) if title: st.header(title) if show_text_input : text = st.text_area("Enter text you want to visualize NER classes for below", text, key=key) if sub_title : st.subheader(sub_title) if generate_code_sample: st.code(get_code_for_viz('NER',StreamlitUtilsOS.extract_name(pipe),text)) if ner_tags is None: ner_tags = StreamlitUtilsOS.get_NER_tags_in_pipe(pipe) if not show_color_selector : if show_label_select: exp = st.expander("Select entity labels to highlight") label_select = exp.multiselect( "These labels are predicted by the NER model. Select which ones you want to display", options=ner_tags,default=list(ner_tags)) else : label_select = ner_tags pipe.viz(text,write_to_streamlit=True, viz_type='ner',labels_to_viz=label_select,viz_colors=colors, streamlit_key=key) else : # TODO WIP color select cols = st.columns(3) exp = cols[0].beta_expander("Select entity labels to display") color = st.color_picker('Pick A Color', '#00f900',key = key) color = cols[2].color_picker('Pick A Color for a specific entity label', '#00f900',key = key) tag2color = cols[1].selectbox('Pick a ner tag to color', ner_tags,key = key) colors[tag2color]=color if show_table : st.write(pipe.predict(text, output_level='chunk'),key = key) if show_infos : # VizUtilsStreamlitOS.display_infos() StreamlitVizTracker.display_model_info(pipe.nlu_ref, pipes = [pipe]) StreamlitVizTracker.display_footer()
def main(): st.markdown("# Data visualization tool using Streamlit") st.title('My first app') st.text('Fixed width text') st.markdown('_Markdown_') # see * st.latex(r''' e^{i\pi} + 1 = 0 ''') st.write('Most objects') # df, err, func, keras! st.write(['st', 'is <', 3]) # see * st.title('My title') st.header('My header') st.subheader('My sub') st.sidebar.button('Hit me') st.checkbox('Check me out') st.radio('Radio', [1,2,3]) st.selectbox('Select', [1,2,3]) st.multiselect('Multiselect', [1,2,3]) st.slider('Slide me', min_value=0, max_value=10) st.select_slider('Slide to select', options=[1,'2']) st.text_input('Enter some text') st.number_input('Enter a number') st.text_area('Area for textual entry') st.date_input('Date input') st.time_input('Time entry') st.file_uploader('File uploader') st.color_picker('Pick a color') # st.balloons() st.error('Error message') st.warning('Warning message') st.info('Info message') st.success('Success message') st.spinner() option = st.sidebar.selectbox('How would you like to be contacted?', ('Email', 'Home phone', 'Mobile phone')) st.sidebar.write('You selected:', option) test = st.sidebar.multiselect('Multiselect2', [1,2,3]) st.sidebar.write('You selected:', test)
def draw_all(key): st.write(""" # Hello Hi **there!** This is `code`. ``` This is block code. ``` """) radio_markdown = """ h2. Select a number --- You have **3** choices! """ st.checkbox("Cool?", key=key, help='Press to confirm checkbox') st.radio("Pick a number", [1, 2, 3], key=key, help=radio_markdown) st.button("Click me!", key=key) st.slider("Pick a number", key=key) st.select_slider("Pick a number", [1, 2, 3], key=key) st.number_input("Pick a number", key=key) st.text_input("Pick a number", key=key) st.text_area("Pick a number", key=key) st.selectbox("Pick a number", [1, 2, 3], key=key) st.multiselect("Pick a number", [1, 2, 3], key=key) st.file_uploader("Pick a file", key=key) st.color_picker("Favorite color", key=key) with st.beta_expander("Expand me!"): st.write("hi") st.progress(0.6) st.json({"data": [1, 2, 3, 4]}) st.dataframe({"data": [1, 2, 3, 4]}) st.table({"data": [1, 2, 3, 4]}) st.line_chart({"data": [1, 2, 3, 4]}) st.help(st.write)
def _display_y_axis_settings(self, y_axis_settings): # Customize x axis label color and add add value to x axis settings y_axis_label_color = st.color_picker("Y Axis Label Color") y_axis_settings["labelColor"] = y_axis_label_color # Customize x axis label color and add add value to y axis settings y_axis_label_font_size = st.slider("Y Axis Label Font Size", min_value=6, max_value=20, value=8, step=1) y_axis_settings["labelFontSize"] = y_axis_label_font_size # Customize the offset value for the x axis y_axis_offset = st.slider( "Y Axis Offset (offset to diplace the axis from the edge)", min_value=0, max_value=20, value=0, step=1, ) y_axis_settings["offset"] = y_axis_offset # Customize x axis grid color y_axis_tick_color = st.color_picker("Y Axis Tick Color") y_axis_settings["tickColor"] = y_axis_tick_color # Customize x axis width y_axis_tick_width = st.slider("Y Axis Tick Size", min_value=0, max_value=30, value=2, step=1) y_axis_settings["tickSize"] = y_axis_tick_width return y_axis_settings
def main(): # Set up your sidebar here st.sidebar.title("The Sidebar") st.sidebar.header("Interactive Widgets:") button = st.sidebar.button("Button") checkbox = st.sidebar.checkbox("Checkbox", value=True) radio = st.sidebar.radio("Radio", options=[1, 2, 3], index=2) selectbox = st.sidebar.selectbox("Selectbox", options=["a", "b", "c"], index=1) mult_options = ["Hack", "to", "the", "Future"] multiselect = st.sidebar.multiselect("Multiselect", options=mult_options, default=mult_options) slider = st.sidebar.slider("Slider", min_value=-10, max_value=10, value=2, step=1) select_options = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] select_slider = st.sidebar.select_slider("Select Slider", options=select_options, value=("Monday", "Friday")) # Set up your page here st.title("My Streamlit Application") "### _This_ is a 'magic' command using **markdown!**" content_spot = st.empty() st.header("More Interactive Widgets") text_input = st.text_input("Text Input") number_input = st.number_input("Number Input", value=0.75, min_value=0.0, max_value=1.0) text_area = st.text_area("Text Area", height=100) date_input = st.date_input("Date Input") time_input = st.time_input("Time Input") file_uploader = st.file_uploader("File Uploader") color_picker = st.color_picker("Color Picker", value="#C137A2") # Add content past_values = cached_function() past_values.append(True) content_spot.markdown(f"<p style='color: {color_picker};'> You've taken " f"{len(past_values)} actions </p>", unsafe_allow_html=True)
def render(assay): with st.sidebar.beta_expander('Customizations'): interface.info('Rename the labels.<br>Merge by giving the same name.') lab_map = {} pal = assay.get_palette() for lab in np.unique(assay.get_labels()): col1, col2 = st.beta_columns([1, 0.15]) with col1: new_name = st.text_input(f'Give a new name to {lab}', lab) with col2: st.markdown(f"<p style='margin-bottom:34px'></p>", unsafe_allow_html=True) pal[lab] = st.color_picker('', pal[lab], key=f'colorpicker-{lab}') if new_name != lab: lab_map[lab] = new_name pal[new_name] = pal[lab] del pal[lab] return lab_map, pal
def _display_title_settings(self, title_settings): # Customize font size and add value to title settings title_font_size = st.slider("Font Size", min_value=10, max_value=60, value=14, step=1) title_settings["fontSize"] = title_font_size # Customize color and add add value to title settings title_color = st.color_picker("Title Color") title_settings["color"] = title_color title_anchor = st.selectbox("Title Position", ["Start", "Middle", "End"], index=1) title_settings["anchor"] = title_anchor.lower() title_offset = st.slider("Title Offset", min_value=0, max_value=40, value=5, step=1) title_settings['offset'] = title_offset return title_settings
import streamlit as st from datetime import datetime default_tooltip = """ This is a really long tooltip. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut turpis vitae justo ornare venenatis a vitae leo. Donec mollis ornare ante, eu ultricies tellus ornare eu. Donec eros risus, ultrices ut eleifend vel, auctor eu turpis. In consectetur erat vel ante accumsan, a egestas urna aliquet. Nullam eget sapien eget diam euismod eleifend. Nulla purus enim, finibus ut velit eu, malesuada dictum nulla. In non arcu et risus maximus fermentum eget nec ante. """.strip() st.text_input("some input text", "default text", help=default_tooltip) st.number_input("number input", value=1, help=default_tooltip) st.checkbox("some checkbox", help=default_tooltip) st.radio("best animal", ("tiger", "giraffe", "bear"), 0, help=default_tooltip) st.button("some button", help=default_tooltip) st.selectbox("selectbox", ("a", "b", "c"), 0, help=default_tooltip) st.time_input("time", datetime(2019, 7, 6, 21, 15), help=default_tooltip) st.date_input("date", datetime(2019, 7, 6, 21, 15), help=default_tooltip) st.slider("slider", 0, 100, 50, help=default_tooltip) st.color_picker("color picker", help=default_tooltip) st.file_uploader("file uploader", help=default_tooltip) st.multiselect("multiselect", ["a", "b", "c"], ["a", "b"], help=default_tooltip) st.text_area("textarea", help=default_tooltip) st.select_slider("selectslider", options=["a", "b", "c"], help=default_tooltip)
# Copyright 2018-2020 Streamlit Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import streamlit as st c1 = st.color_picker("Default Color") st.write("Color 1", c1) c2 = st.color_picker("New Color", "#EB144C") st.write("Color 2", c2)
def test_color_picker_serde(self): cp = st.color_picker("cp", key="cp") check_roundtrip("cp", cp)
# 多文件载入 uploaded_files = st.file_uploader("Choose a CSV file", accept_multiple_files=True) for uploaded_file in uploaded_files: bytes_data = uploaded_file.read() st.write("filename:", uploaded_file.name) st.write(bytes_data) """ ### 4.12 颜色选择 `streamlit.color_picker(label, value=None, key=None)` 选择颜色的一个组件 """ color = st.color_picker('Pick A Color', '#00f900') st.write('The current color is', color) ''' ## 4 控制组件 - Control flow ''' """ ### 4.1 输入框 只有输入了,才会继续进行下去... """ name = st.text_input('Name') if not name: st.warning('Please input a name.') st.stop() st.success(f'Thank you for inputting a name. {name}')
def test_invalid_value_type_error(self): """Tests that when the value type is invalid, an exception is generated""" with pytest.raises(StreamlitAPIException) as exc_message: st.color_picker("the label", 1234567)
def test_invalid_string(self): """Tests that when the string doesn't match regex, an exception is generated""" with pytest.raises(StreamlitAPIException) as exc_message: st.color_picker("the label", "#invalid-string")
import streamlit as st st.color_picker("Background color hex: ", "#eee", key="main") st.sidebar.color_picker("Background color hex: ", "#eee", key="sidebar")
st.title("Divinding in columns and color picking") # Default colors for initial value colors = [ "#FFC0CB", "#2E8B57", "#BA55D3", "#4169E1", "#F4A460", "#696969", "#F5F5DC", "#FF1493", "#FFFF00", "#00FA9A" ] # n columns n = st.slider("How many columns?", 1, 10, 5, 1) columns = st.beta_columns(n) div_colors = {} for i in range(1, n + 1): with columns[i - 1]: col = st.color_picker("", colors[i - 1], key=f"column {i}") st.markdown(f'<div class="div-{i} column"> Hello </div>', unsafe_allow_html=True) div_colors[i] = col st.write("---") # 2 columns proportionally divided prop = st.slider("Divide the columns", 1, 99, 50, 1) prop_columns = st.beta_columns((prop, 100 - prop)) with prop_columns[0]: col = st.color_picker("", "#F5F5DC", key=f"left") st.markdown('<div class="div-left column"> Left </div>', unsafe_allow_html=True) div_colors["left"] = col
import numpy as np import pickle import load_data import time # make a timer on the page # with st.spinner(text='In progress'): # time.sleep(5) # st.success('Done') # input images / video -- link to the file you want # could upload file to the specific df file = st.file_uploader('File uploader') # have user pick a color st.color_picker('Pick a color') # name of the app we want to appear on the top of the screen st.title("My Awesome Flower Predictor") st.header("We predict Iris types") st.subheader("No joke") # get input from user about Iris and predict what type/species it is # load data df_iris = load_data.load_iris() # make plots on the page st.plotly_chart(px.scatter(df_iris, 'sepal_width', 'sepal_length')) # make it an option to show only if the user wants to
coluna = st.multiselect('Colunas', df.columns) st.multiselect('Valores', df.values[1]) texto = st.text_input('Altura', '200') texto = st.slider('Slide me', min_value=100, max_value=600) st.bar_chart(df, 100, int(texto)) progress = st.slider('Progresso', min_value=1, max_value=100) st.progress(progress) if progress == 100: st.spinner() with st.spinner(text='Corrida...'): time.sleep(5) st.success('Terminou') st.balloons() st.color_picker('Aquarela') st.button('Hit me') st.checkbox('Check me out') st.radio('Radio', [1, 2, 3]) st.selectbox('Select', [1, 2, 3]) st.multiselect('Multiselect', [1, 2, 3]) st.select_slider('Slide to select', options=[1, '2']) st.text_input('Enter some text') st.number_input('Enter a number') st.text_area('Area for textual entry') st.date_input('Date input') st.time_input('Time entry')
# Copyright 2018-2022 Streamlit Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import streamlit as st c1 = st.color_picker("Default Color") st.write("Color 1", c1) c2 = st.color_picker("New Color", "#EB144C") st.write("Color 2", c2) c3 = st.color_picker("Disabled", disabled=True) st.write("Color 3", c3)
def run_home_page(): original_df = load_data() filtered_df = filtered_data() property_crimes = [ 'BURGLARY/BREAKING ENTERING', 'THEFT', 'UNAUTHORIZED USE' ] crime_selection = original_df[( original_df.ucr_group.isin(property_crimes))] with header: st.title('Neighborhood Safety Prediction App') bgcolor = st.color_picker("") st.write('Property Crimes') day_text = " ".join(crime_selection['ucr_group'].tolist()) mywordcloud = WordCloud(background_color=bgcolor).generate(day_text) fig = plt.figure() plt.imshow(mywordcloud, interpolation='bilinear') plt.axis('off') st.pyplot(fig) st.markdown(""" This web application analyzes the safety of city of Cincinnati neighborhoods based on historical records of property crimes within the Cincinnati Metro area. The end product provides a 'safety score' for a specific location at the time of inquiry. Using geo-coded address as input data from the end user along with demographic information such as age, gender and race, the app translates the likelihood of an arrest at the location as a measure of actual and perceived safety at the location for the user. The main goal of this project is protect users from becoming victims as opposed to catching a repeat offender. * **Python libraries:** base64, pandas, streamlit * **Data source:** [data.cincinnati-oh.gov](https://data.cincinnati-oh.gov/Safety/PDI-Police-Data-Initiative-Crime-Incidents/k59e-2pvf). * **Part I Crime Offense:** THEFT, BURGLARY/BREAKING ENTERING, UNAUTHORIZED USE """) with dataset: st.header('City of Cincinnati Crime Data') st.write(original_df.head()) st.write(original_df.shape) st.write('Original data dimensions: ' + str(original_df.shape[0]) + ' rows and ' + str(crime_selection.shape[1]) + ' columns') st.subheader('Crime Type Distribution on Property Crime Dataset') crime_type_dist = pd.DataFrame( crime_selection['ucr_group'].value_counts()) st.write(crime_type_dist) crime_graph = px.bar(crime_type_dist, x=crime_type_dist.index, y='ucr_group', color=crime_type_dist.index) st.plotly_chart(crime_graph) with features: st.header('Selected Features for Further Engineering') st.write(filtered_df.head().T) st.write(filtered_df.shape) st.write('Filtered data dimensions: ' + str(filtered_df.shape[0]) + ' rows and ' + str(filtered_df.shape[1]) + ' columns') with maps: st.header('Map of Crime Incidents') st.map(filtered_df)
st.markdown('----') st.button('Click here') st.checkbox('Check') st.radio('Radio', [1, 2, 3]) st.selectbox('Select', [1, 2, 3]) st.multiselect('Multiple selection', [21, 85, 53]) st.slider('Slide', min_value=10, max_value=20) st.select_slider('Slide to select', options=[1, 2, 3, 4]) st.text_input('Enter some text') st.number_input('Enter a number') st.text_area('Text area') st.date_input('Date input') st.time_input('Time input') st.file_uploader('File uploader') st.color_picker('Color Picker') st.markdown('----') st.header("Miscellaneous widgets") st.markdown("Bold: this is a __bold__ parameter") st.markdown("Italic: this is a _italic_ parameter") st.markdown("Bold italic: this is a __*bold italic*__ parameter") st.markdown("weblink: [Google](https://www.google.com)") st.markdown('A section') st.write('Lorem ipsum widgets') st.markdown('----') st.subheader('Lorem ipsum widgets') st.write('Lorem ipsum widgets') st.markdown('----')