Template request | Bug report | Generate Data Product
Tags: #streamlit #app #ml #ai #operations #plotly
Author: Gagan Bhatia
Description: This notebook provides a step-by-step guide to creating a Streamlit app that can make predictions based on user input.
from naas_drivers import streamlit
Create the Python file necessary to deploy Streamlit app.
%%writefile streamlit_app.py
from naas_drivers import streamlit, plotly, yahoofinance, prediction
import streamlit as st
TICKER = "TSLA"
date_from = -100 # 1OO days max to feed the naas_driver for prediction
date_to = "today"
DATA_POINT = 20
df_yahoo = yahoofinance.get(tickers=TICKER,
date_from=date_from,
date_to=date_to).dropna().reset_index(drop=True)
df_predict = prediction.get(dataset=df_yahoo,
date_column='Date',
column="Close",
data_points=DATA_POINT,
prediction_type="all").sort_values("Date", ascending=False).reset_index(drop=True)
fig = plotly.linechart(df_predict,
x="Date",
y=["Close", "ARIMA", "SVR", "LINEAR", "COMPOUND"],
showlegend=True,
title=f"{TICKER} predictions as of today, for next {str(DATA_POINT)} days.")
st.write("# Prediction for {}".format(TICKER))
st.plotly_chart(fig, width=1200)
streamlit.add("streamlit_app.py", port=9999, debug=True)