Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# limitations under the License.
"""An example of showing geographic data."""
import streamlit as st
import pandas as pd
import numpy as np
import altair as alt
import pydeck as pdk
DATE_TIME = "date/time"
DATA_URL = (
"http://s3-us-west-2.amazonaws.com/streamlit-demo-data/uber-raw-data-sep14.csv.gz"
)
st.title("Uber Pickups in New York City")
st.markdown(
"""
This is a demo of a Streamlit app that shows the Uber pickups
geographical distribution in New York City. Use the slider
to pick a specific hour and look at how the charts change.
[See source code](https://github.com/streamlit/demo-uber-nyc-pickups/blob/master/app.py)
""")
@st.cache(persist=True)
def load_data(nrows):
data = pd.read_csv(DATA_URL, nrows=nrows)
lowercase = lambda x: str(x).lower()
data.rename(lowercase, axis="columns", inplace=True)
data[DATE_TIME] = pd.to_datetime(data[DATE_TIME])
return data
@st.cache(allow_output_mutation=True)
def report(colormap):
optimum= metrics.Optimum(ground_truth,prediction)
r= optimum.report(colormap=colormap)
r_pie_= optimum.report(colormap=False)
return r, r_pie_
r, r_pie_ = report(colormap)
st.dataframe(r)
st.title("Confusion matrix percentages")
option_method = st.selectbox("Method",df_methods_pie_chart["method"], index = 0)
st.plotly_chart(pie_chart(r_pie_,option_method))
st.title("Multi-level pie chart")
labels = list(r_pie_.index)
option_method2 = st.multiselect("Methods", options = labels, default = labels)
st.pyplot(nested_pie_chart(r_pie_,option_method2))
# Checking for stationarity in the series
st.title('Checking stationarity')
# If a function is not forced by the user, use the default pipeline
if force_transformation == None:
ts, d, D, seasonality, acf_pacf_data, transformation_function, test_stationarity_code = test_stationary(df[y], plot_adfuller_result, data_frequency)
else:
ts, d, D, seasonality, acf_pacf_data, transformation_function, test_stationarity_code = test_stationary(df[y], plot_adfuller_result, data_frequency,
force_transformation_technique = force_transformation,
custom_transformation_size = (difference_size, seasonal_difference_size))
st.title('ACF and PACF estimation')
p, q, P, Q = find_acf_pacf(acf_pacf_data, seasonality)
st.markdown('**Suggested parameters for your model**: {}x{}{}'.format((p, d, q), (P, D, Q), (seasonality)))
st.title('Time to train!')
st.write('Select the terms on the side bar and click "Do your Magic!" button')
try:
p, d, q, P, D, Q, s, train_model, periods_to_forecast, execute_grid_search = sidebar_menus('terms', test_set_size, seasonality, (p, d, q, P, D, Q, seasonality), df=ts)
except ValueError:
error_message = '''
A problem has occurred while we tried to find the best initial parameters for p, d, and q.
Please, check if your FREQUENCY field is correct for your dataset. For example, if your dataset
was collected in a daily basis, check if you selected DAILY in the FREQUENCY field.
'''
raise ValueError(error_message)
# Showing a warning when Grid Search operation is too expensive
if execute_grid_search:
if data_frequency in ['Hourly', 'Daily'] or p >= 5 or q >= 5:
warning_grid_search = '''
def main():
st.title("Verify that st.pyplot and matplotlib show the same things.")
# Plot labels
title = "An Extremely and Really Really Long Long Long Title"
xLabel = "Very long long x label"
yLabel = "Very long long y label"
# Generate data
n = 200
xData = np.random.randn(n, 1) * 30 + 30
yData = np.random.randn(n, 1) * 30
data = np.random.randn(n, 2)
# Generate plot
fig, ax = plt.subplots(figsize=(4.5, 4.5))
sns.set_context(rc={"font.size": 10})
p = sns.regplot(x=xData, y=yData, data=data, ci=None, ax=ax, color="grey")
# 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
from bokeh.plotting import figure
st.title("Bokeh Charts")
st.subheader("Line Plot")
# prepare some data
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]
# create a new plot with a title and axis labels
p = figure(title="simple line example", x_axis_label="x", y_axis_label="y")
# add a line renderer with legend and line thickness
p.line(x, y, legend="Trend", line_width=2)
# show the results
st.bokeh_chart(p)
#Habría que cambiarlo de momento añadimos datos por aquí
#prediction_1=np.load("data/prediction_1.npy")
#Y_Test_1=np.load("data/Y_Test_1.npy")
#data = [(Y_Test_1, prediction_1)]
keys = list(data.keys())
model = st.selectbox(label="Select a model:", options = keys, index = 0 )
graphs = metrics.Graphs([data[model]])
st.sidebar.title("Other graphs")
option_graphs = st.sidebar.selectbox("Select",df_graphs["graphs"])
option_threshold,option_fill,option_legend,number_threshold= configuration(other_graph = True)
if option_graphs == "Precision and Recall vs Decision threshold":
st.title("Precision and Recall vs Decision threshold")
if option_threshold:
methods_list = methods_Precision_and_Recall()
else:
methods_list=None
g = other_graphics(graphs, option_graphs, option_threshold,option_legend,methods_list, number_threshold)
st.plotly_chart(g)
elif option_graphs == "True positive rate and False positive rate vs Decision threshold":
st.title("True positive rate and False positive rate vs Decision threshold")
if option_threshold:
methods_list = methods_tprate_and_fprate()
else:
methods_list=None
g = other_graphics(graphs, option_graphs, option_threshold,option_legend,methods_list, number_threshold)
st.plotly_chart(g)
def main():
st.title("Iris EDA App")
st.subheader("EDA Web App with Streamlit ")
st.markdown("""
#### Description
+ This is a simple Exploratory Data Analysis of the Iris Dataset depicting the various species built with Streamlit.
#### Purpose
+ To show a simple EDA of Iris using Streamlit framework.
""")
# Your code goes below
# Our Dataset
my_dataset = "iris.csv"
# To Improve speed and cache data
@st.cache(persist=True)
def explore_data(dataset):
import streamlit as st
import sys
# # Uncomment this as a block.
# # This tests that errors before the first st call get caught.
# def foo():
# # EXPECTED: inline exception
# a = not_a_real_variable # noqa: F821 pylint:disable=undefined-variable,unused-variable
# foo()
# # Uncomment this as a block.
# # This tests that errors before the first st call get caught.
# if True # EXPECTED: modal dialog
st.title("Syntax error test")
st.info("Uncomment the comment blocks in the source code one at a time.")
st.write(
"""
Here's the source file for you to edit:
```
examples/syntax_error.py
```
"""
)
st.write("(Some top text)")
# # Uncomment this as a block.
# a = not_a_real_variable # EXPECTED: inline exception.
import streamlit as st
import pandas as pd
import numpy as np
from dateutil.parser import parse
st.title('Vega Lite support')
# --
st.header('Basic charts')
df = pd.DataFrame({'a': np.random.randn(50), 'b': np.random.randn(50)})
st.vega_lite.line_chart(df)
st.vega_lite.area_chart(df)
df = pd.DataFrame(np.random.randn(200, 3), columns=['a', 'b', 'c'])
st.vega_lite.scatter_chart(df)
# --
st.header('Custom charts')
#st.plotly_chart(g, width=702, height=900)
elif option_curve == "PRC Curve":
st.title("PRC Curve")
if option_threshold:
methods_list_prc= methods_prc()
else:
methods_list_prc=None
g = grafico(graphs, option_curve, option_threshold,option_fill,option_legend,methods_list_prc, number_threshold)
st.plotly_chart(g)
#st.plotly_chart(g, width=702, height=900)
elif option_curve == "Both":
st.title("ROC and PRC curves")
if option_threshold:
methods_list_both = methods_both()
else:
methods_list_both = None
g = grafico(graphs, option_curve, option_threshold,option_fill,option_legend,methods_list_both, number_threshold)
st.plotly_chart(g)
#st.plotly_chart(g, height=670, width=770)