Spaces:
No application file
No application file
MaryDatascientist
commited on
Commit
•
c09585b
1
Parent(s):
7f21399
Delete strApp.py
Browse files
strApp.py
DELETED
@@ -1,110 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import hopsworks
|
3 |
-
import os
|
4 |
-
import joblib
|
5 |
-
import pandas as pd
|
6 |
-
import dataframe_image as dfi
|
7 |
-
import streamlit as st
|
8 |
-
import joblib
|
9 |
-
import numpy as np
|
10 |
-
import folium
|
11 |
-
from streamlit_folium import st_folium, folium_static
|
12 |
-
import json
|
13 |
-
import time
|
14 |
-
from datetime import timedelta, datetime
|
15 |
-
from branca.element import Figure
|
16 |
-
from API_call_visual_crossing import *
|
17 |
-
from API_call_AQI import *
|
18 |
-
#----------------------------------HEADER + TITLE
|
19 |
-
def fancy_header(text, font_size=24):
|
20 |
-
res = f'<span style="color:#ff5f27; font-size: {font_size}px;">{text}</span>'
|
21 |
-
st.markdown(res, unsafe_allow_html=True )
|
22 |
-
st.title('⛅️Air Quality Prediction Project🌩')
|
23 |
-
|
24 |
-
progress_bar = st.sidebar.header('⚙️ Working Progress')
|
25 |
-
progress_bar = st.sidebar.progress(0)
|
26 |
-
st.write(36 * "-")
|
27 |
-
|
28 |
-
#-----------------------------------CONNECTING TO HOPSWORKS
|
29 |
-
fancy_header('\n📡 Connecting to Hopsworks Feature Store...')
|
30 |
-
|
31 |
-
project = hopsworks.login()
|
32 |
-
|
33 |
-
st.write("Successfully connected!✔️")
|
34 |
-
progress_bar.progress(20)
|
35 |
-
#------------------------------------ PREDICTION
|
36 |
-
|
37 |
-
st.write(36 * "-")
|
38 |
-
fancy_header('\n☁️ Getting data for predict ...')
|
39 |
-
city = 'Paris'
|
40 |
-
date = ''
|
41 |
-
|
42 |
-
|
43 |
-
WEATHER_API_KEY ="V7VHELUHHCY7JPQ8332XPR8A9"# = os.getenv('WEATHER_API_KEY')
|
44 |
-
|
45 |
-
df_weather = get_weather_df(city, date, WEATHER_API_KEY)
|
46 |
-
next_7_days = df_weather["date"]
|
47 |
-
data_7_days = df_weather.drop('date', axis=1)
|
48 |
-
|
49 |
-
#mr = project.get_model_registry()
|
50 |
-
#model = mr.get_best_model("aqi_model", "r2", "max")
|
51 |
-
#model_dir = model.download()
|
52 |
-
#model = joblib.load(model_dir + "/aqi_model.pkl")
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
from urllib.request import urlopen
|
57 |
-
#from sklearn.externals import joblib
|
58 |
-
import joblib
|
59 |
-
|
60 |
-
model = joblib.load(urlopen('https://github.com/reyrobs/Scalable_ML_Project_AQ/raw/main/aqi_model.pkl'))
|
61 |
-
|
62 |
-
pred_7_days = model.predict(data_7_days)
|
63 |
-
|
64 |
-
df = pd.DataFrame(data=pred_7_days, index=next_7_days, columns=[f"AQI Predictions for the next 7 days"], dtype=int)
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
progress_bar.progress(60)
|
69 |
-
#----------------------------------
|
70 |
-
|
71 |
-
st.write(36 * "-")
|
72 |
-
fancy_header(f"🗺 Processing the map...")
|
73 |
-
|
74 |
-
fig = Figure(width=550,height=350)
|
75 |
-
|
76 |
-
my_map = folium.Map(location=[58, 20], zoom_start=3.71)
|
77 |
-
fig.add_child(my_map)
|
78 |
-
folium.TileLayer('Stamen Terrain').add_to(my_map)
|
79 |
-
folium.TileLayer('Stamen Toner').add_to(my_map)
|
80 |
-
folium.TileLayer('Stamen Water Color').add_to(my_map)
|
81 |
-
folium.TileLayer('cartodbpositron').add_to(my_map)
|
82 |
-
folium.TileLayer('cartodbdark_matter').add_to(my_map)
|
83 |
-
folium.LayerControl().add_to(my_map)
|
84 |
-
|
85 |
-
#Determining Paris
|
86 |
-
coords = [48.862, 2.346]
|
87 |
-
#-----
|
88 |
-
city = "Pris"
|
89 |
-
country="France"
|
90 |
-
text=""
|
91 |
-
|
92 |
-
#-----
|
93 |
-
text +=str(pred_7_days[0])
|
94 |
-
#-----
|
95 |
-
st.sidebar.write(df)
|
96 |
-
|
97 |
-
folium.Marker(
|
98 |
-
location=coords, popup=text, tooltip=f"<strong>{city}</strong>"
|
99 |
-
).add_to(my_map)
|
100 |
-
|
101 |
-
|
102 |
-
# call to render Folium map in Streamlit
|
103 |
-
folium_static(my_map)
|
104 |
-
progress_bar.progress(80)
|
105 |
-
st.sidebar.write("-" * 36)
|
106 |
-
|
107 |
-
|
108 |
-
st.sidebar.write(df)
|
109 |
-
progress_bar.progress(100)
|
110 |
-
st.button("Re-run")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|