Spaces:
Running
Running
File size: 1,513 Bytes
1ae03dd 388226f 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 51 52 53 54 55 56 57 58 59 |
import streamlit as st
import hopsworks
import joblib
import pandas as pd
import numpy as np
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🌩')
progress_bar = st.sidebar.header('Working Progress')
progress_bar = st.sidebar.progress(0)
st.write(36 * "-")
fancy_header('\n Connecting to Hopsworks Feature Store...')
project = hopsworks.login()
st.write("Successfully connected!✔️")
progress_bar.progress(20)
st.write(36 * "-")
fancy_header('\n Getting data from thee weather API...')
today = datetime.date.today()
city = "vienna"
weekly_data = get_weather_data_weekly(city, today)
progress_bar.progress(50)
progress_bar.progress(60)
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")
progress_bar.progress(80)
st.sidebar.write("-" * 36)
preds = model.predict(data_encoder(weekly_data)).astype(int)
poll_level = get_aplevel(preds.T.reshape(-1, 1))
next_week = [(datetime.today() + timedelta(days=d)).strftime('%A') for d in range(1, 7)]
df = pd.DataFrame(data=preds, index=["eg"], columns=[f"AQI Predictions for {next_day}" for next_day in next_week], dtype=int)
st.sidebar.write(df)
progress_bar.progress(100)
st.button("Re-run") |