Spaces:
Runtime error
Runtime error
Commit
·
d4e6ae3
1
Parent(s):
94aa604
first demo version
Browse files- app.py +39 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
import datetime
|
| 4 |
+
import pandas as pd
|
| 5 |
+
|
| 6 |
+
import hopsworks
|
| 7 |
+
|
| 8 |
+
def get_price():
|
| 9 |
+
|
| 10 |
+
project = hopsworks.login()
|
| 11 |
+
fs = project.get_feature_store()
|
| 12 |
+
|
| 13 |
+
price_pred_fg = fs.get_feature_group(
|
| 14 |
+
name="price_predictions",
|
| 15 |
+
version=1
|
| 16 |
+
).read()
|
| 17 |
+
|
| 18 |
+
dates = [
|
| 19 |
+
(datetime.datetime.now() + datetime.timedelta(days=i)).strftime("%Y-%m-%d")
|
| 20 |
+
for i in range(1, 8)]
|
| 21 |
+
days_ahead = list(range(1, 8))
|
| 22 |
+
|
| 23 |
+
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)]
|
| 24 |
+
price_predictions = pd.DataFrame()
|
| 25 |
+
price_predictions['date'] = dates
|
| 26 |
+
price_predictions['price'] = prices
|
| 27 |
+
# print(price_predictions)
|
| 28 |
+
return price_predictions
|
| 29 |
+
|
| 30 |
+
demo = gr.Interface(
|
| 31 |
+
fn=get_price,
|
| 32 |
+
title="Energy Price Prediction",
|
| 33 |
+
description="Predicted daily average energy prices over the coming 7 days",
|
| 34 |
+
allow_flagging="never",
|
| 35 |
+
inputs=[],
|
| 36 |
+
outputs=gr.Timeseries(x="date", y=["price"]))
|
| 37 |
+
|
| 38 |
+
demo.launch()
|
| 39 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
hopsworks
|