IsacLorentz commited on
Commit
7c8bd5f
1 Parent(s): ea06202

set share to true

Browse files
Files changed (1) hide show
  1. app.py +23 -17
app.py CHANGED
@@ -1,45 +1,51 @@
1
- import gradio as gr
2
- import numpy as np
3
  import datetime
4
- import pandas as pd
5
- import matplotlib.pyplot as plt
6
 
7
  import hopsworks
 
 
 
 
 
 
8
 
9
  def get_price():
10
 
11
  project = hopsworks.login()
12
  fs = project.get_feature_store()
13
 
14
- price_pred_fg = fs.get_feature_group(
15
- name="price_predictions",
16
- version=1
17
- ).read()
18
-
19
  dates = [
20
  (datetime.datetime.now() + datetime.timedelta(days=i)).strftime("%Y-%m-%d")
21
- for i in range(1, 8)]
 
22
  days_ahead = list(range(1, 8))
23
 
24
- prices = [price_pred_fg.loc[(price_pred_fg['date'] == dates[i]) & (price_pred_fg['days_ahead'] == days_ahead[i])]['predicted_price'].values[0] for i in range(0,7)]
 
 
 
 
 
 
25
  price_predictions = pd.DataFrame()
26
- price_predictions['date'] = dates
27
- price_predictions['price'] = prices
28
 
29
  fig = plt.figure()
30
- price_predictions.plot(kind='line', x='date', y='price')
31
 
32
  # print(price_predictions)
33
  return fig
34
 
 
35
  demo = gr.Interface(
36
  fn=get_price,
37
  title="Energy Price Prediction",
38
  description="Predicted daily average energy prices over the coming 7 days",
39
  allow_flagging="never",
40
  inputs=[],
41
- outputs=['plot']
42
  )
43
 
44
- demo.launch()
45
-
 
 
 
1
  import datetime
 
 
2
 
3
  import hopsworks
4
+ import matplotlib.pyplot as plt
5
+ import numpy as np
6
+ import pandas as pd
7
+
8
+ import gradio as gr
9
+
10
 
11
  def get_price():
12
 
13
  project = hopsworks.login()
14
  fs = project.get_feature_store()
15
 
16
+ price_pred_fg = fs.get_feature_group(name="price_predictions", version=1).read()
17
+
 
 
 
18
  dates = [
19
  (datetime.datetime.now() + datetime.timedelta(days=i)).strftime("%Y-%m-%d")
20
+ for i in range(1, 8)
21
+ ]
22
  days_ahead = list(range(1, 8))
23
 
24
+ prices = [
25
+ price_pred_fg.loc[
26
+ (price_pred_fg["date"] == dates[i])
27
+ & (price_pred_fg["days_ahead"] == days_ahead[i])
28
+ ]["predicted_price"].values[0]
29
+ for i in range(0, 7)
30
+ ]
31
  price_predictions = pd.DataFrame()
32
+ price_predictions["date"] = dates
33
+ price_predictions["price"] = prices
34
 
35
  fig = plt.figure()
36
+ price_predictions.plot(kind="line", x="date", y="price")
37
 
38
  # print(price_predictions)
39
  return fig
40
 
41
+
42
  demo = gr.Interface(
43
  fn=get_price,
44
  title="Energy Price Prediction",
45
  description="Predicted daily average energy prices over the coming 7 days",
46
  allow_flagging="never",
47
  inputs=[],
48
+ outputs=["plot"],
49
  )
50
 
51
+ demo.launch(share=True)