import gradio as gr import numpy as np import datetime import pandas as pd import matplotlib.pyplot as plt import hopsworks 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()