File size: 1,326 Bytes
1ae03dd
 
 
 
 
 
 
60999f9
1ae03dd
 
60999f9
 
1ae03dd
 
 
 
 
 
 
 
 
 
 
60999f9
1ae03dd
 
 
 
 
 
 
 
 
 
 
 
 
bb98c8a
1ae03dd
60999f9
1ae03dd
 
 
60999f9
1ae03dd
60999f9
1ae03dd
bb98c8a
60999f9
1ae03dd
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
import streamlit as st
import hopsworks
import joblib
import pandas as pd
from datetime import timedelta, datetime
from functions import *


def fancy_header(text, font_size=24):
    res = f'<span style="color:#ff5f27; font-size: {font_size}px;">{text}</span>'
    st.markdown(res, unsafe_allow_html=True)


st.title('Air Quality Prediction Project🌩')

st.write(36 * "-")
fancy_header('\n Connecting to Hopsworks Feature Store...')

project = hopsworks.login()

st.write("Successfully connected!✔️")

st.write(36 * "-")
fancy_header('\n Getting data from Feature Store...')

today = datetime.date.today()
city = "vienna"
weekly_data = get_weather_data_weekly(city, today)


st.write(36 * "-")

mr = project.get_model_registry()
model = mr.get_best_model("aqi_model", "rmse", "min")
model_dir = model.download()
model = joblib.load(model_dir + "/aqi_model.pkl")

st.sidebar.write("-" * 36)


preds = model.predict(data_encoder(weekly_data)).astype(int)
poll_level = get_aplevel(preds.T.reshape(-1, 1))

next_week = [[(today + timedelta(days=d)).strftime('%Y-%m-%d'),(today + timedelta(days=d)).strftime('%A')] for d in range(1, 7)]

df = pd.DataFrame(data=[preds, poll_level], index=["AQI", "Air pollution level"], columns=[f"AQI Predictions for {next_day}" for next_day in next_week])

st.write(df)

st.button("Re-run")