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