a10 commited on
Commit
de5d5cf
·
1 Parent(s): a5c2f24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -37
app.py CHANGED
@@ -239,43 +239,43 @@ model = from_pretrained_keras("keras-io/timeseries_forecasting_for_weather")
239
  #%%
240
  st.set_option('deprecation.showPyplotGlobalUse', False)
241
  def plot():
242
- n = st.sidebar.slider("Step", min_value = 1, max_value=5, value = 1)
243
- def show_plot(plot_data, delta, title):
244
- labels = ["History", "True Future", "Model Prediction"]
245
- marker = [".-", "rx", "go"]
246
- time_steps = list(range(-(plot_data[0].shape[0]), 0))
247
- if delta:
248
- future = delta
249
- else:
250
- future = 0
251
-
252
- plt.title(title)
253
- for i, val in enumerate(plot_data):
254
- if i:
255
- plt.plot(future, plot_data[i], marker[i], markersize=10, label=labels[i])
256
- else:
257
- plt.plot(time_steps, plot_data[i].flatten(), marker[i], label=labels[i])
258
- plt.legend(loc='lower center', bbox_to_anchor=(0.5, 1.05),
259
- ncol=3, fancybox=True, shadow=True)
260
- plt.xlim([time_steps[0], (future + 5) * 2])
261
- plt.xlabel("Time-Step")
262
- plt.show()
263
- return
264
-
265
-
266
- for x, y in dataset_val.take(n):
267
- if ("0" == "mycustom"):
268
- show_plot(
269
- [x[0][:, 1].numpy(), y[0].numpy(), model.predict(x)[0]],
270
- 12,
271
- f"{n} Step Prediction",
272
- )
273
- if ("0" != "mycustom"):
274
- show_plot(
275
- [x[0][:, 0].numpy(), y[0].numpy(), model.predict(x)[0]],
276
- 12,
277
- f"{n} Step Prediction",
278
- )
279
 
280
 
281
  fig = plot()
 
239
  #%%
240
  st.set_option('deprecation.showPyplotGlobalUse', False)
241
  def plot():
242
+ n = st.sidebar.slider("Step", min_value = 1, max_value=5, value = 1)
243
+ def show_plot(plot_data, delta, title):
244
+ labels = ["History", "True Future", "Model Prediction"]
245
+ marker = [".-", "rx", "go"]
246
+ time_steps = list(range(-(plot_data[0].shape[0]), 0))
247
+ if delta:
248
+ future = delta
249
+ else:
250
+ future = 0
251
+
252
+ plt.title(title)
253
+ for i, val in enumerate(plot_data):
254
+ if i:
255
+ plt.plot(future, plot_data[i], marker[i], markersize=10, label=labels[i])
256
+ else:
257
+ plt.plot(time_steps, plot_data[i].flatten(), marker[i], label=labels[i])
258
+ plt.legend(loc='lower center', bbox_to_anchor=(0.5, 1.05),
259
+ ncol=3, fancybox=True, shadow=True)
260
+ plt.xlim([time_steps[0], (future + 5) * 2])
261
+ plt.xlabel("Time-Step")
262
+ plt.show()
263
+ return
264
+
265
+
266
+ for x, y in dataset_val.take(n):
267
+ if ("0" == "mycustom"):
268
+ show_plot(
269
+ [x[0][:, 1].numpy(), y[0].numpy(), model.predict(x)[0]],
270
+ 12,
271
+ f"{n} Step Prediction",
272
+ )
273
+ if ("0" != "mycustom"):
274
+ show_plot(
275
+ [x[0][:, 0].numpy(), y[0].numpy(), model.predict(x)[0]],
276
+ 12,
277
+ f"{n} Step Prediction",
278
+ )
279
 
280
 
281
  fig = plot()