Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
selection = st.sidebar.radio("Go to", list(PAGES.keys()))
page = PAGES[selection]
try:
src.st_extensions.write_page(page)
except Exception as _:
st.error("Error. Something wen't wrong! Please refresh the app")
st.sidebar.title("Contributions")
st.sidebar.info(
"You are very welcome to **contribute** your awesome comments, questions, "
"resources, apps or code.\n"
"- [Create Issue](https://github.com/MarcSkovMadsen/awesome-streamlit/issues)\n"
"- [Create Pull Request](https://github.com/MarcSkovMadsen/awesome-streamlit/pulls)\n"
"- [View Source Code](https://github.com/MarcSkovMadsen/awesome-streamlit)\n\n"
)
st.sidebar.title("About")
st.sidebar.info(
"This app is maintained by Marc Skov Madsen. "
"You can learn more about me at [datamodelsanalytics.com](https://datamodelsanalytics.com)."
def main():
components = load_data()
title = st.empty()
st.sidebar.title("Options")
def label(symbol):
a = components.loc[symbol]
return symbol + " - " + a.Security
if st.sidebar.checkbox("View companies list"):
st.dataframe(
components[["Security", "GICS Sector", "Date first added", "Founded"]]
)
st.sidebar.subheader("Select asset")
asset = st.sidebar.selectbox(
"Click below to select a new asset",
components.index.sort_values(),
index=3,
format_func=label,
def main():
'''Set main() function. Includes sidebar navigation and respective routing.'''
st.sidebar.title("Explore")
app_mode = st.sidebar.selectbox( "Choose an Action", [
"About",
"Choose an Emotion",
"Choose an Artist",
"Classify a Song",
"Emotional Spectrum",
"Show Source Code"
])
# clear tmp
clear_tmp()
# nav
if app_mode == "About": show_about()
elif app_mode == "Choose an Emotion": explore_classified()
elif app_mode == 'Choose an Artist': explore_artists()
from transform_time_series import transform_time_series
pd.set_option('display.float_format', lambda x: '%.3f' % x) # Granting that pandas won't use scientific notation for floating fields
description = '''
**Arauto** is an open-source project that will help you to forecast the future from historical data.
It uses statiscal models to give you accurated predictions for time series data, which is helpful for
financial data, network traffic, sales, and much more.
'''
# Description
st.image('img/banner.png')
st.write('*An equivalent exchange: you give me data, I give you answers*')
st.write(description)
### SIDEBAR
st.sidebar.title('Your data')
filename, df = file_selector()
st.markdown('## **First lines of your data**')
st.dataframe(df.head(10)) # First lines of DataFrame
ds_column, y, data_frequency, test_set_size, exog_variables = sidebar_menus('feature_target', df=df)
# Name of the exogenous variables
exog_variables_names = exog_variables
# If there's not exogenous variables, it returns None
exog_variables = df[exog_variables] if len(exog_variables) > 0 else None
# Show plots
plot_menu_title = st.sidebar.markdown('### Charts')
SPACY_MODEL_NAMES = ["blackstone"]
DEFAULT_TEXT = "Mark Zuckerberg is the CEO of Facebook."
HTML_WRAPPER = """<div style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem; margin-bottom: 2.5rem">{}</div>"""
@st.cache(ignore_hash=True)
def process_text(model_name, text):
nlp = spacy.load('en_blackstone_proto')
print ("model loaded!")
return nlp(text)
st.sidebar.title("Interactive spaCy visualizer")
st.sidebar.markdown(
"""
Process text with [spaCy](https://spacy.io) models and visualize named entities,
dependencies and more. Uses spaCy's built-in
[displaCy](http://spacy.io/usage/visualizers) visualizer under the hood.
"""
)
model_load_state = st.info(f"Loading model '{spacy_model}'...")
nlp = spacy.load('en_blackstone_proto')
model_load_state.empty()
text = st.text_area("Text to analyze", DEFAULT_TEXT)
doc = process_text(spacy_model, text)
from spacy import displacy
import srsly
FILES = ["drugs_training.jsonl", "drugs_eval.jsonl"]
LABEL = "DRUG"
HTML_WRAPPER = "<div style="border-bottom: 1px solid #ccc; padding: 20px 0">{}</div>"
SETTINGS = {"style": "ent", "manual": True, "options": {"colors": {LABEL: "#d1bcff"}}}
@st.cache(allow_output_mutation=True)
def load_data(filepath):
return list(srsly.read_jsonl(filepath))
st.sidebar.title("Data visualizer")
st.sidebar.markdown(
"Visualize the annotations using [displaCy](https://spacy.io/usage/visualizers) "
"and view stats about the datasets."
)
data_file = st.sidebar.selectbox("Dataset", FILES)
data = load_data(data_file)
n_no_ents = 0
n_total_ents = 0
st.header(f"{data_file} ({len(data)})")
for eg in data:
row = {"text": eg["text"], "ents": eg.get("spans", [])}
n_total_ents += len(row["ents"])
if not row["ents"]:
n_no_ents += 1
html = displacy.render(row, **SETTINGS).replace("\n\n", "\n")
st.sidebar.title("Navigation")
selection = st.sidebar.radio("Go to", list(PAGES.keys()))
page = PAGES[selection]
with st.spinner(f"Loading {selection} ..."):
ast.shared.components.write_page(page)
st.sidebar.title("Contribute")
st.sidebar.info(
"This an open source project and you are very welcome to **contribute** your awesome "
"comments, questions, resources and apps as "
"[issues](https://github.com/MarcSkovMadsen/awesome-streamlit/issues) of or "
"[pull requests](https://github.com/MarcSkovMadsen/awesome-streamlit/pulls) "
"to the [source code](https://github.com/MarcSkovMadsen/awesome-streamlit). "
)
st.sidebar.title("About")
st.sidebar.info(
"""
This app is maintained by Marc Skov Madsen. You can learn more about me at
def main():
components = load_data()
title = st.empty()
st.sidebar.title("Options")
def label(symbol):
a = components.loc[symbol]
return symbol + ' - ' + a.Security
if st.sidebar.checkbox('View companies list'):
st.dataframe(components[['Security',
'GICS Sector',
'Date first added',
'Founded']])
st.sidebar.subheader('Select asset')
asset = st.sidebar.selectbox('Click below to select a new asset',
components.index.sort_values(), index=3,
format_func=label)
title.title(components.loc[asset].Security)
def main():
"""Main function. Run this to run the app"""
st.sidebar.title("Layout and Style Experiments")
st.sidebar.header("Settings")
st.markdown(
"""
# Layout and Style Experiments
The basic question is: Can we create a multi-column dashboard with plots, numbers and text using
the [CSS Grid](https://gridbyexample.com/examples)?
Can we do it with a nice api?
Can have a dark theme?
"""
)
select_block_container_style()
add_resources_section()
The complete demo is [implemented in less than 300 lines of Python](https://github.com/streamlit/demo-self-driving/blob/master/app.py) and illustrates all the major building blocks of Streamlit.
### Questions? Comments?
Please ask in the [Streamlit community](https://discuss.streamlit.io).
""")
# Download external dependencies.info = st.empty()
if not st.checkbox("MAYBE DOWNLOAD 250MB OF DATA TO THE SERVER. THIS MIGHT TAKE A FEW MINUTES!"):
return
for filename in EXTERNAL_DEPENDENCIES.keys():
download_file(filename)
st.sidebar.title("Self Driving Cars")
run_the_app()