File size: 1,322 Bytes
0bd33c6
 
 
 
 
 
 
 
 
 
 
 
 
5481207
 
 
0bd33c6
 
 
 
 
 
 
 
 
 
 
a861bdf
0bd33c6
 
 
 
856d042
a861bdf
0bd33c6
 
 
 
 
 
79b10c2
0bd33c6
 
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
import gradio as gr
from PIL import Image
import hopsworks

project = hopsworks.login(project="ID2223_L2")
fs = project.get_feature_store()

predictions_fg = fs.get_feature_group(name="weather_predictions", version=1)
query = predictions_fg.select_all()
predictions_df = query.read(read_options={"use_hive": True})

predictions_df = predictions_df.sort_values(by=["timestamp_local"])

print(predictions_df)
print(predictions_df.tail(4))

dataset_api = project.get_dataset_api()

dataset_api.download("Resources/weather/last_prediction.txt")
dataset_api.download("Resources/weather/prediction_graph.png")

def latest_prediction(path):
   f = open(path,"r")
   date = f.readline()
   temp = f.readline()
   f.close()

   return "## Prediction at time   : "+date+"\n\n ## Predicted temperature:"+temp

with gr.Blocks() as demo:
    with gr.Row():
      with gr.Column():
          gr.Label("Latest Predicted Forecast")
          gr.Markdown(latest_prediction("last_prediction.txt"))
      with gr.Column():          
          gr.Label("Graph of Recent Predictions")      
          input_img = gr.Image("prediction_graph.png", elem_id="temperature-graph")
    with gr.Row():
      with gr.Column():
          gr.Label("Recent Prediction History")
          gr.DataFrame(predictions_df, interactive=False)    

demo.launch()