Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,9 +6,6 @@ import pandas as pd
|
|
6 |
from datetime import datetime
|
7 |
import plotly.graph_objects as go
|
8 |
|
9 |
-
def predict_future_prices(ticker, periods=1825):
|
10 |
-
data = download_data(ticker)
|
11 |
-
|
12 |
def download_data(ticker, start_date='2010-01-01'):
|
13 |
"""
|
14 |
주식 데이터를 다운로드하고 포맷을 조정하는 함수
|
@@ -56,22 +53,22 @@ def predict_future_prices(ticker, periods=1825):
|
|
56 |
fig.add_trace(go.Scatter(x=data['ds'], y=data['y'], mode='lines', name='Actual (Black)', line=dict(color='black')))
|
57 |
|
58 |
return fig, forecast_prophet[['ds', 'yhat', 'yhat_lower', 'yhat_upper']], future_lr[['ds', 'yhat']]
|
59 |
-
|
60 |
-
css = """footer { visibility: hidden; }"""
|
61 |
|
62 |
-
|
|
|
63 |
with gr.Row():
|
64 |
ticker_input = gr.Textbox(value="AAPL", label="Enter Stock Ticker for Forecast")
|
65 |
periods_input = gr.Number(value=1825, label="Forecast Period (days)")
|
66 |
forecast_button = gr.Button("Generate Forecast")
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
71 |
forecast_button.click(
|
72 |
fn=predict_future_prices,
|
73 |
inputs=[ticker_input, periods_input],
|
74 |
outputs=[forecast_chart, forecast_data_prophet, forecast_data_lr]
|
75 |
)
|
76 |
|
77 |
-
app.launch()
|
|
|
6 |
from datetime import datetime
|
7 |
import plotly.graph_objects as go
|
8 |
|
|
|
|
|
|
|
9 |
def download_data(ticker, start_date='2010-01-01'):
|
10 |
"""
|
11 |
주식 데이터를 다운로드하고 포맷을 조정하는 함수
|
|
|
53 |
fig.add_trace(go.Scatter(x=data['ds'], y=data['y'], mode='lines', name='Actual (Black)', line=dict(color='black')))
|
54 |
|
55 |
return fig, forecast_prophet[['ds', 'yhat', 'yhat_lower', 'yhat_upper']], future_lr[['ds', 'yhat']]
|
|
|
|
|
56 |
|
57 |
+
# Gradio 인터페이스 설정 및 실행
|
58 |
+
with gr.Blocks() as app:
|
59 |
with gr.Row():
|
60 |
ticker_input = gr.Textbox(value="AAPL", label="Enter Stock Ticker for Forecast")
|
61 |
periods_input = gr.Number(value=1825, label="Forecast Period (days)")
|
62 |
forecast_button = gr.Button("Generate Forecast")
|
63 |
+
|
64 |
+
forecast_chart = gr.Plot(label="Forecast Chart")
|
65 |
+
forecast_data_prophet = gr.Dataframe(label="Prophet Forecast Data")
|
66 |
+
forecast_data_lr = gr.Dataframe(label="Linear Regression Forecast Data")
|
67 |
+
|
68 |
forecast_button.click(
|
69 |
fn=predict_future_prices,
|
70 |
inputs=[ticker_input, periods_input],
|
71 |
outputs=[forecast_chart, forecast_data_prophet, forecast_data_lr]
|
72 |
)
|
73 |
|
74 |
+
app.launch()
|