PricePrediction / app.py
IsacLorentz's picture
set share to true
7c8bd5f
raw
history blame contribute delete
No virus
1.2 kB
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)