Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -17,18 +17,25 @@ def download_data(ticker, start_date='2010-01-01'):
|
|
17 |
raise ValueError("Expected 'Adj Close' in columns")
|
18 |
return data
|
19 |
|
20 |
-
def predict_future_prices(ticker):
|
21 |
-
|
22 |
-
data =
|
23 |
-
|
|
|
24 |
model.fit(data)
|
25 |
-
|
|
|
26 |
forecast = model.predict(future)
|
27 |
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
# ์ด์ ์ด ํจ์๋ฅผ Gradio ์ธํฐํ์ด์ค์ ์ฐ๊ฒฐํ์ฌ ์ฌ์ฉ์๊ฐ
|
32 |
|
33 |
|
34 |
# Gradio ์ธํฐํ์ด์ค ์ค์
|
|
|
17 |
raise ValueError("Expected 'Adj Close' in columns")
|
18 |
return data
|
19 |
|
20 |
+
def predict_future_prices(ticker, periods=1825): # 5๋
๊ฐ์ ๋ฐ์ดํฐ ์์ธก
|
21 |
+
data = yf.download(ticker, start="2010-01-01")['Adj Close'].reset_index()
|
22 |
+
data.rename(columns={'Date': 'ds', 'Adj Close': 'y'}, inplace=True)
|
23 |
+
|
24 |
+
model = Prophet(daily_seasonality=False, weekly_seasonality=False, yearly_seasonality=True)
|
25 |
model.fit(data)
|
26 |
+
|
27 |
+
future = model.make_future_dataframe(periods=periods, freq='D')
|
28 |
forecast = model.predict(future)
|
29 |
|
30 |
+
# Timestamp๋ฅผ ๋ฌธ์์ด๋ก ๋ณํ
|
31 |
+
forecast['ds'] = forecast['ds'].dt.strftime('%Y-%m-%d')
|
32 |
+
|
33 |
+
fig = go.Figure(data=[go.Scatter(x=forecast['ds'], y=forecast['yhat'], mode='lines', name='Forecast')])
|
34 |
+
fig.update_layout(title=f'5-Year Future Price Forecast for {ticker}', xaxis_title='Date', yaxis_title='Predicted Price')
|
35 |
+
|
36 |
+
return fig, forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].to_dict(orient='records')
|
37 |
|
38 |
+
# ์ด์ ์ด ํจ์๋ฅผ Gradio ์ธํฐํ์ด์ค์ ์ฐ๊ฒฐํ์ฌ ์ฌ์ฉ์๊ฐ ์๊ฐํ๋ฅผ ๋ณผ ์ ์๊ฒ ํฉ๋๋ค.
|
39 |
|
40 |
|
41 |
# Gradio ์ธํฐํ์ด์ค ์ค์
|