aiqtech commited on
Commit
4111b35
ยท
verified ยท
1 Parent(s): fe5131f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -46,23 +46,24 @@ def predict_future_prices(ticker, periods=1825):
46
  X_future = pd.to_numeric(pd.Series(range(len(data), len(data) + len(future_lr))))
47
  future_lr['yhat'] = model_lr.predict(X_future.values.reshape(-1, 1))
48
 
49
- # NeuralProphet ๋ชจ๋ธ ์ƒ์„ฑ ๋ฐ ํ•™์Šต
50
  model_np = NeuralProphet()
51
- model_np.fit(data, freq='D')
52
  future_np = model_np.make_future_dataframe(data, periods=periods)
53
  forecast_np = model_np.predict(future_np)
54
-
55
- # ์˜ˆ์ธก ๊ฒฐ๊ณผ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ
56
  forecast_prophet['ds'] = forecast_prophet['ds'].dt.strftime('%Y-%m-%d')
57
- forecast_np['ds'] = forecast_np['ds'].dt.strftime('%Y-%m-%d')
58
  fig = go.Figure()
59
  fig.add_trace(go.Scatter(x=forecast_prophet['ds'], y=forecast_prophet['yhat'], mode='lines', name='Prophet Forecast (Blue)', line=dict(color='blue')))
60
  fig.add_trace(go.Scatter(x=future_lr['ds'], y=future_lr['yhat'], mode='lines', name='Linear Regression Forecast (Red)', line=dict(color='red')))
61
  fig.add_trace(go.Scatter(x=forecast_np['ds'], y=forecast_np['yhat1'], mode='lines', name='NeuralProphet Forecast (Green)', line=dict(color='green')))
62
  fig.add_trace(go.Scatter(x=data['ds'], y=data['y'], mode='lines', name='Actual (Black)', line=dict(color='black')))
63
-
64
  return fig, forecast_prophet[['ds', 'yhat', 'yhat_lower', 'yhat_upper']], future_lr[['ds', 'yhat']], forecast_np[['ds', 'yhat1']]
65
 
 
66
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • ๋ฐ ์‹คํ–‰
67
  with gr.Blocks() as app:
68
  with gr.Row():
 
46
  X_future = pd.to_numeric(pd.Series(range(len(data), len(data) + len(future_lr))))
47
  future_lr['yhat'] = model_lr.predict(X_future.values.reshape(-1, 1))
48
 
49
+ # NeuralProphet ๋ชจ๋ธ ์ƒ์„ฑ ๋ฐ ํ•™์Šต
50
  model_np = NeuralProphet()
51
+ metrics = model_np.fit(data, freq='D')
52
  future_np = model_np.make_future_dataframe(data, periods=periods)
53
  forecast_np = model_np.predict(future_np)
54
+
55
+ # ์˜ˆ์ธก ๊ฒฐ๊ณผ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ
56
  forecast_prophet['ds'] = forecast_prophet['ds'].dt.strftime('%Y-%m-%d')
57
+ forecast_np['ds'] = pd.to_datetime(forecast_np['ds']).dt.strftime('%Y-%m-%d')
58
  fig = go.Figure()
59
  fig.add_trace(go.Scatter(x=forecast_prophet['ds'], y=forecast_prophet['yhat'], mode='lines', name='Prophet Forecast (Blue)', line=dict(color='blue')))
60
  fig.add_trace(go.Scatter(x=future_lr['ds'], y=future_lr['yhat'], mode='lines', name='Linear Regression Forecast (Red)', line=dict(color='red')))
61
  fig.add_trace(go.Scatter(x=forecast_np['ds'], y=forecast_np['yhat1'], mode='lines', name='NeuralProphet Forecast (Green)', line=dict(color='green')))
62
  fig.add_trace(go.Scatter(x=data['ds'], y=data['y'], mode='lines', name='Actual (Black)', line=dict(color='black')))
63
+
64
  return fig, forecast_prophet[['ds', 'yhat', 'yhat_lower', 'yhat_upper']], future_lr[['ds', 'yhat']], forecast_np[['ds', 'yhat1']]
65
 
66
+
67
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • ๋ฐ ์‹คํ–‰
68
  with gr.Blocks() as app:
69
  with gr.Row():