Johan713 commited on
Commit
62985bb
·
verified ·
1 Parent(s): 278cb18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -125,16 +125,16 @@ def create_test_plot(train_data, test_data, predicted_data, company_name):
125
  fig = go.Figure()
126
 
127
  fig.add_trace(go.Scatter(
128
- x=train_data.index,
129
- y=train_data['Close'],
130
  mode='lines',
131
  name='Training Data',
132
  line=dict(color='blue')
133
  ))
134
 
135
  fig.add_trace(go.Scatter(
136
- x=test_data.index,
137
- y=test_data['Close'],
138
  mode='lines',
139
  name='Actual (Test) Data',
140
  line=dict(color='green')
@@ -142,7 +142,7 @@ def create_test_plot(train_data, test_data, predicted_data, company_name):
142
 
143
  if predicted_data is not None:
144
  fig.add_trace(go.Scatter(
145
- x=test_data.index, # Align predicted data with test data
146
  y=predicted_data['yhat'][-len(test_data):],
147
  mode='lines',
148
  name='Predicted Data',
@@ -288,7 +288,7 @@ def test_model():
288
  st.metric("Mean Squared Error", f"{mse:.4f}")
289
  st.metric("Root Mean Squared Error", f"{rmse:.4f}")
290
 
291
- plot = create_test_plot(predictor.data, test_data, test_pred, company_name)
292
  st.plotly_chart(plot, use_container_width=True)
293
  else:
294
  st.error("Failed to evaluate the model. The evaluation metrics are None.")
 
125
  fig = go.Figure()
126
 
127
  fig.add_trace(go.Scatter(
128
+ x=train_data['ds'],
129
+ y=train_data['y'],
130
  mode='lines',
131
  name='Training Data',
132
  line=dict(color='blue')
133
  ))
134
 
135
  fig.add_trace(go.Scatter(
136
+ x=test_data['ds'],
137
+ y=test_data['y'],
138
  mode='lines',
139
  name='Actual (Test) Data',
140
  line=dict(color='green')
 
142
 
143
  if predicted_data is not None:
144
  fig.add_trace(go.Scatter(
145
+ x=test_data['ds'], # Align predicted data with test data
146
  y=predicted_data['yhat'][-len(test_data):],
147
  mode='lines',
148
  name='Predicted Data',
 
288
  st.metric("Mean Squared Error", f"{mse:.4f}")
289
  st.metric("Root Mean Squared Error", f"{rmse:.4f}")
290
 
291
+ plot = create_test_plot(predictor.data, test_data.reset_index().rename(columns={'Date': 'ds', 'Close': 'y'}), test_pred, company_name)
292
  st.plotly_chart(plot, use_container_width=True)
293
  else:
294
  st.error("Failed to evaluate the model. The evaluation metrics are None.")