Spaces:
Runtime error
Runtime error
removed hardcoded value
Browse files
app.py
CHANGED
|
@@ -238,10 +238,29 @@ def plot(ts_index, test_dataset, forecasts, prediction_length):
|
|
| 238 |
mode='lines',
|
| 239 |
)
|
| 240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
# Create the figure
|
| 242 |
fig = make_subplots(rows=1, cols=1)
|
| 243 |
fig.add_trace(actual_data, row=1, col=1)
|
| 244 |
fig.add_trace(forecast_data, row=1, col=1)
|
|
|
|
|
|
|
| 245 |
|
| 246 |
# Set layout and title
|
| 247 |
fig.update_layout(
|
|
@@ -256,7 +275,7 @@ def plot(ts_index, test_dataset, forecasts, prediction_length):
|
|
| 256 |
def do_prediction(days_to_predict: int):
|
| 257 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 258 |
# Define the desired prediction length
|
| 259 |
-
prediction_length =
|
| 260 |
freq = "1D" # Daily frequency
|
| 261 |
|
| 262 |
dataset = load_dataset("thesven/BTC-Daily-Avg-Market-Value")
|
|
|
|
| 238 |
mode='lines',
|
| 239 |
)
|
| 240 |
|
| 241 |
+
forecast_median = np.median(forecasts[ts_index][0][:prediction_length])
|
| 242 |
+
forecast_median_data = go.Scatter(
|
| 243 |
+
x=index[target_length:],
|
| 244 |
+
y=[forecast_median] * prediction_length,
|
| 245 |
+
name="Prediction Median",
|
| 246 |
+
mode='lines',
|
| 247 |
+
)
|
| 248 |
+
|
| 249 |
+
forecast_std = np.std(forecasts[ts_index][0][:prediction_length])
|
| 250 |
+
forecast_std_data = go.Scatter(
|
| 251 |
+
x=index[target_length:],
|
| 252 |
+
y=[forecast_median + forecast_std] * prediction_length,
|
| 253 |
+
name="Prediction Std",
|
| 254 |
+
mode='lines',
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
|
| 258 |
# Create the figure
|
| 259 |
fig = make_subplots(rows=1, cols=1)
|
| 260 |
fig.add_trace(actual_data, row=1, col=1)
|
| 261 |
fig.add_trace(forecast_data, row=1, col=1)
|
| 262 |
+
fig.add_trace(forecast_median_data, row=1, col=1)
|
| 263 |
+
fig.add_trace(forecast_std_data, row=1, col=1)
|
| 264 |
|
| 265 |
# Set layout and title
|
| 266 |
fig.update_layout(
|
|
|
|
| 275 |
def do_prediction(days_to_predict: int):
|
| 276 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 277 |
# Define the desired prediction length
|
| 278 |
+
prediction_length = days_to_predict # Number of time steps to predict into the future
|
| 279 |
freq = "1D" # Daily frequency
|
| 280 |
|
| 281 |
dataset = load_dataset("thesven/BTC-Daily-Avg-Market-Value")
|