Update app.py
Browse files
app.py
CHANGED
@@ -93,6 +93,13 @@ class StockPredictor:
|
|
93 |
future[column] = self.data[column].iloc[-1] # Use last known value
|
94 |
|
95 |
forecast = self.model.predict(future)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
return forecast
|
97 |
except Exception as e:
|
98 |
print(f"Error predicting with Prophet model: {str(e)}")
|
@@ -468,7 +475,8 @@ def predict_stock_prices():
|
|
468 |
st.plotly_chart(fig, use_container_width=True)
|
469 |
|
470 |
# Create forecast components plot using Plotly
|
471 |
-
components
|
|
|
472 |
n_components = len(components.columns)
|
473 |
|
474 |
fig_components = make_subplots(rows=n_components, cols=1,
|
|
|
93 |
future[column] = self.data[column].iloc[-1] # Use last known value
|
94 |
|
95 |
forecast = self.model.predict(future)
|
96 |
+
|
97 |
+
# Calculate components
|
98 |
+
forecast['trend'] = forecast['trend']
|
99 |
+
forecast['yearly'] = forecast['yearly'] if 'yearly' in forecast.columns else 0
|
100 |
+
forecast['weekly'] = forecast['weekly'] if 'weekly' in forecast.columns else 0
|
101 |
+
forecast['daily'] = forecast['daily'] if 'daily' in forecast.columns else 0
|
102 |
+
|
103 |
return forecast
|
104 |
except Exception as e:
|
105 |
print(f"Error predicting with Prophet model: {str(e)}")
|
|
|
475 |
st.plotly_chart(fig, use_container_width=True)
|
476 |
|
477 |
# Create forecast components plot using Plotly
|
478 |
+
# Instead of using predict_components, we'll extract the components from the predictions DataFrame
|
479 |
+
components = predictions[['trend', 'yearly', 'weekly', 'daily']]
|
480 |
n_components = len(components.columns)
|
481 |
|
482 |
fig_components = make_subplots(rows=n_components, cols=1,
|