Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def object_detector_ui():
st.sidebar.markdown("# Model")
confidence_threshold = st.sidebar.slider("Confidence threshold", 0.0, 1.0, 0.5, 0.01)
overlap_threshold = st.sidebar.slider("Overlap threshold", 0.0, 1.0, 0.3, 0.01)
return confidence_threshold, overlap_threshold
#filename = st.sidebar.text_input('Enter the filename of a csv-file.')
agree = st.sidebar.checkbox('Display raw data.')
if agree:
st.dataframe(data)
samples = data.transcription
text_labels = [label_name.lower() for label_name in data.medical_specialty]
labels = enc.fit_transform(np.array(text_labels))
labels = np.ravel(labels)
unique_values, counts = np.unique(labels, return_counts=True)
relative_counts = counts/np.sum(counts)
st.write("The initial data set contains",np.shape(unique_values)[0],"classes and",data.shape[0],"samples.")
# EXTRACT SAMPLES AND LABELS.
st.sidebar.header("Preprocessing class distributions.")
treshhold_to_consider = st.sidebar.slider("Minimum fraction of class in data set in order to be considered.", min_value=0.01, max_value=0.1, value=0.02, step=0.01)
classes_to_consider = unique_values[relative_counts>=treshhold_to_consider]
index_to_consider = np.empty((labels.shape[0]),dtype="bool")
for i,label in enumerate(labels):
if label in classes_to_consider:
index_to_consider[i] = True
else:
index_to_consider[i] = False
# EXTRACT CLASSES
labels = labels[index_to_consider]
samples = samples[index_to_consider]
unique_values, counts = np.unique(labels, return_counts=True)
relative_counts = counts/np.sum(counts)
label_names = enc.inverse_transform(unique_values)
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)
if st.sidebar.checkbox("View company info", True):
st.table(components.loc[asset])
data0 = load_quotes(asset)
data = data0.copy().dropna()
data.index.name = None
section = st.sidebar.slider(
"Number of quotes",
min_value=30,
max_value=min([2000, data.shape[0]]),
value=500,
step=10,
)
data2 = data[-section:]["Adj Close"].to_frame("Adj Close")
sma = st.sidebar.checkbox("SMA")
if sma:
period = st.sidebar.slider(
"SMA period", min_value=5, max_value=500, value=20, step=1
)
data[f"SMA {period}"] = data["Adj Close"].rolling(period).mean()
data2[f"SMA {period}"] = data[f"SMA {period}"].reindex(data2.index)
def sidebar_settings():
"""Add selection section for setting setting the max-width and padding
of the main block container"""
st.sidebar.header("Bokeh Experiments")
max_width_100_percent = st.sidebar.checkbox("Max-width?", False)
if not max_width_100_percent:
max_width = st.sidebar.slider("Select max-width in px", 100, 2000, 1200, 100)
else:
max_width = 1200
_set_block_container_style(max_width, max_width_100_percent)
# Show plots
plot_menu_title = st.sidebar.markdown('### Charts')
plot_menu_text = st.sidebar.text('Select which charts you want to see')
show_absolute_plot = sidebar_menus('absolute')
show_seasonal_decompose = sidebar_menus('seasonal')
show_adfuller_test = sidebar_menus('adfuller')
show_train_prediction = sidebar_menus('train_predictions')
show_test_prediction = sidebar_menus('test_predictions')
force_transformation = sidebar_menus('force_transformations') # You can force a transformation technique
difference_size = None
seasonal_difference_size = None
if ('Custom Difference') in force_transformation:
# If the user selects a custom transformation, enable the difference options
difference_size = st.sidebar.slider('Difference size: ', 0, 30, 1)
seasonal_difference_size = st.sidebar.slider('Seasonal Difference size: ', 0, 30, 1)
plot_adfuller_result = False
if show_adfuller_test:
plot_adfuller_result = True
# Transform DataFrame to a Series
df = transform_time_series(df, ds_column, data_frequency, y)
# Show the historical plot?
if show_absolute_plot:
st.markdown('# Historical data ')
df[y].plot(color='green')
plt.title('Absolute historical data')
st.pyplot()
data = data0.copy().dropna()
data.index.name = None
section = st.sidebar.slider(
"Number of quotes",
min_value=30,
max_value=min([2000, data.shape[0]]),
value=500,
step=10,
)
data2 = data[-section:]["Adj Close"].to_frame("Adj Close")
sma = st.sidebar.checkbox("SMA")
if sma:
period = st.sidebar.slider(
"SMA period", min_value=5, max_value=500, value=20, step=1
)
data[f"SMA {period}"] = data["Adj Close"].rolling(period).mean()
data2[f"SMA {period}"] = data[f"SMA {period}"].reindex(data2.index)
sma2 = st.sidebar.checkbox("SMA2")
if sma2:
period2 = st.sidebar.slider(
"SMA2 period", min_value=5, max_value=500, value=100, step=1
)
data[f"SMA2 {period2}"] = data["Adj Close"].rolling(period2).mean()
data2[f"SMA2 {period2}"] = data[f"SMA2 {period2}"].reindex(data2.index)
st.subheader("Chart")
st.line_chart(data2)
def main():
st.title('Crawling and Rendering in Python')
st.sidebar.markdown('## Indexing Options')
i_type = st.sidebar.radio('Term Frequency type?',('bm25', 'tfidf'))
title_boost = st.sidebar.slider('How much of a boost to give titles?', 1, 5, 2, 1)
st.sidebar.markdown('## Search Options')
search_query = st.sidebar.text_input('Search Query', '')
sim_weight = st.sidebar.slider('How much weight to give to term similarity?', 0.0, 1.0, 0.5, 0.1)
pr_weight = st.sidebar.slider('How much weight to give to PageRank?', 0.0, 1.0, 0.5, 0.1)
bert_weight = st.sidebar.slider('How much weight to give to bert?', 0.0, 1.0, 0.5, 0.1)
st.markdown('## Crawling')
# Crawling (First Wave)
crawler = crawl_data(cfg.crawler_seed)
st.markdown('## Rendering')
# Rendering (Second Wave)
crawler = render_data(crawler)
st.markdown('## Indexing')
# Build the index
indexer = index_data(crawler, i_type, title_boost)
plot_menu_title = st.sidebar.markdown('### Charts')
plot_menu_text = st.sidebar.text('Select which charts you want to see')
show_absolute_plot = sidebar_menus('absolute')
show_seasonal_decompose = sidebar_menus('seasonal')
show_adfuller_test = sidebar_menus('adfuller')
show_train_prediction = sidebar_menus('train_predictions')
show_test_prediction = sidebar_menus('test_predictions')
force_transformation = sidebar_menus('force_transformations') # You can force a transformation technique
difference_size = None
seasonal_difference_size = None
if ('Custom Difference') in force_transformation:
# If the user selects a custom transformation, enable the difference options
difference_size = st.sidebar.slider('Difference size: ', 0, 30, 1)
seasonal_difference_size = st.sidebar.slider('Seasonal Difference size: ', 0, 30, 1)
plot_adfuller_result = False
if show_adfuller_test:
plot_adfuller_result = True
# Transform DataFrame to a Series
df = transform_time_series(df, ds_column, data_frequency, y)
# Show the historical plot?
if show_absolute_plot:
st.markdown('# Historical data ')
df[y].plot(color='green')
plt.title('Absolute historical data')
st.pyplot()
# Show decomposition plot
def object_detector_ui():
st.sidebar.markdown("# Model")
confidence_threshold = st.sidebar.slider("Confidence threshold", 0.0, 1.0, 0.5, 0.01)
overlap_threshold = st.sidebar.slider("Overlap threshold", 0.0, 1.0, 0.3, 0.01)
return confidence_threshold, overlap_threshold
def main():
"""A Reactive View of the KickstarterDashboard"""
kickstarter_df = get_kickstarter_df()
kickstarter_dashboard = KickstarterDashboard(kickstarter_df=kickstarter_df)
st.markdown(__doc__)
st.info(INFO)
options = get_categories()
categories_selected = st.multiselect("Select Categories", options=options)
if not categories_selected and kickstarter_dashboard.categories:
kickstarter_dashboard.categories = []
else:
kickstarter_dashboard.categories = categories_selected
st.sidebar.title("Selections")
x_range = st.sidebar.slider("Select create_at range", 2009, 2018, (2009, 2018))
y_range = st.sidebar.slider("Select usd_pledged", 0.0, 5.0, (0.0, 5.0))
filter_df = KickstarterDashboard.filter_on_categories(kickstarter_df, categories_selected)
filter_df = kickstarter_dashboard.filter_on_ranges(
filter_df, (pd.Timestamp(x_range[0], 1, 1), pd.Timestamp(x_range[1], 12, 31)), y_range
)
kickstarter_dashboard.scatter_df = filter_df
st.bokeh_chart(hv.render(kickstarter_dashboard.scatter_plot_view()))
st.bokeh_chart(hv.render(kickstarter_dashboard.bar_chart_view()))