aiqtech commited on
Commit
e266db4
ยท
verified ยท
1 Parent(s): 45bf426

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -86,22 +86,22 @@ def predict_future_prices(ticker, periods=1825):
86
  pred_lstm = scaler.inverse_transform(np.array(pred_lstm).reshape(-1, 1))
87
  future_lstm = pd.DataFrame({'ds': future_dates[:len(pred_lstm)], 'yhat': pred_lstm.flatten()})
88
 
89
-
90
- # XGBoost ๋ชจ๋ธ ์ƒ์„ฑ ๋ฐ ํ•™์Šต
91
  model_xgb = XGBRegressor(n_estimators=100, learning_rate=0.1)
92
- model_xgb.fit(X.values.reshape(-1, 1), y)
93
- future_xgb = pd.DataFrame({'ds': future_dates, 'yhat': model_xgb.predict(X_future.values.reshape(-1, 1))})
94
 
95
  # SVR ๋ชจ๋ธ ์ƒ์„ฑ ๋ฐ ํ•™์Šต
96
  model_svr = SVR(kernel='rbf', C=1e3, gamma=0.1)
97
- model_svr.fit(X.values.reshape(-1, 1), y)
98
- future_svr = pd.DataFrame({'ds': future_dates, 'yhat': model_svr.predict(X_future.values.reshape(-1, 1))})
99
 
100
  # Bayesian Regression ๋ชจ๋ธ ์ƒ์„ฑ ๋ฐ ํ•™์Šต
101
  model_bayes = BayesianRidge()
102
- model_bayes.fit(X.values.reshape(-1, 1), y)
103
- future_bayes = pd.DataFrame({'ds': future_dates, 'yhat': model_bayes.predict(X_future.values.reshape(-1, 1))})
104
 
 
105
  # ์˜ˆ์ธก ๊ฒฐ๊ณผ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ
106
  forecast_prophet['ds'] = forecast_prophet['ds'].dt.strftime('%Y-%m-%d')
107
  fig = go.Figure()
@@ -116,6 +116,7 @@ def predict_future_prices(ticker, periods=1825):
116
 
117
  return fig, forecast_prophet[['ds', 'yhat', 'yhat_lower', 'yhat_upper']], future_lr[['ds', 'yhat']], future_arima[['ds', 'yhat']], future_lstm[['ds', 'yhat']], future_xgb[['ds', 'yhat']], future_svr[['ds', 'yhat']], future_bayes[['ds', 'yhat']]
118
 
 
119
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • ๋ฐ ์‹คํ–‰
120
  with gr.Blocks() as app:
121
  with gr.Row():
 
86
  pred_lstm = scaler.inverse_transform(np.array(pred_lstm).reshape(-1, 1))
87
  future_lstm = pd.DataFrame({'ds': future_dates[:len(pred_lstm)], 'yhat': pred_lstm.flatten()})
88
 
89
+ # XGBoost ๋ชจ๋ธ ์ƒ์„ฑ ๋ฐ ํ•™์Šต
 
90
  model_xgb = XGBRegressor(n_estimators=100, learning_rate=0.1)
91
+ model_xgb.fit(X.reshape(-1, 1), y)
92
+ future_xgb = pd.DataFrame({'ds': future_dates, 'yhat': model_xgb.predict(X_future)})
93
 
94
  # SVR ๋ชจ๋ธ ์ƒ์„ฑ ๋ฐ ํ•™์Šต
95
  model_svr = SVR(kernel='rbf', C=1e3, gamma=0.1)
96
+ model_svr.fit(X.reshape(-1, 1), y)
97
+ future_svr = pd.DataFrame({'ds': future_dates, 'yhat': model_svr.predict(X_future)})
98
 
99
  # Bayesian Regression ๋ชจ๋ธ ์ƒ์„ฑ ๋ฐ ํ•™์Šต
100
  model_bayes = BayesianRidge()
101
+ model_bayes.fit(X.reshape(-1, 1), y)
102
+ future_bayes = pd.DataFrame({'ds': future_dates, 'yhat': model_bayes.predict(X_future)})
103
 
104
+
105
  # ์˜ˆ์ธก ๊ฒฐ๊ณผ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ
106
  forecast_prophet['ds'] = forecast_prophet['ds'].dt.strftime('%Y-%m-%d')
107
  fig = go.Figure()
 
116
 
117
  return fig, forecast_prophet[['ds', 'yhat', 'yhat_lower', 'yhat_upper']], future_lr[['ds', 'yhat']], future_arima[['ds', 'yhat']], future_lstm[['ds', 'yhat']], future_xgb[['ds', 'yhat']], future_svr[['ds', 'yhat']], future_bayes[['ds', 'yhat']]
118
 
119
+
120
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • ๋ฐ ์‹คํ–‰
121
  with gr.Blocks() as app:
122
  with gr.Row():