Kr08 commited on
Commit
be4b326
·
verified ·
1 Parent(s): 67781cf

Update stock_analysis.py

Browse files
Files changed (1) hide show
  1. stock_analysis.py +8 -2
stock_analysis.py CHANGED
@@ -20,8 +20,14 @@ def forecast_series(series, model="ARIMA", forecast_period=FORECAST_PERIOD):
20
  model = ARIMA(series, order=(5, 1, 0))
21
  model_fit = model.fit()
22
  forecast = model_fit.forecast(steps=forecast_period, alpha=(1 - CONFIDENCE_INTERVAL))
23
- predictions = forecast.predicted_mean
24
- confidence_intervals = forecast.conf_int()
 
 
 
 
 
 
25
  elif model == "Prophet":
26
  # Implement Prophet forecasting method
27
  pass
 
20
  model = ARIMA(series, order=(5, 1, 0))
21
  model_fit = model.fit()
22
  forecast = model_fit.forecast(steps=forecast_period, alpha=(1 - CONFIDENCE_INTERVAL))
23
+
24
+ # Check if forecast is a numpy array (newer statsmodels) or a ForecastResults object (older statsmodels)
25
+ if isinstance(forecast, np.ndarray):
26
+ predictions = forecast
27
+ confidence_intervals = model_fit.get_forecast(steps=forecast_period).conf_int()
28
+ else:
29
+ predictions = forecast.predicted_mean
30
+ confidence_intervals = forecast.conf_int()
31
  elif model == "Prophet":
32
  # Implement Prophet forecasting method
33
  pass