Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,7 +104,64 @@ with tab1:
|
|
| 104 |
|
| 105 |
|
| 106 |
with col2:
|
| 107 |
-
st.subheader("Parking place near
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
|
| 110 |
# Update button
|
|
|
|
| 104 |
|
| 105 |
|
| 106 |
with col2:
|
| 107 |
+
st.subheader("Parking place near building:")
|
| 108 |
+
|
| 109 |
+
# Function to load the building models
|
| 110 |
+
|
| 111 |
+
@st.cache_data()
|
| 112 |
+
def get_bikelane_mag_model(project=project):
|
| 113 |
+
mr = project.get_model_registry()
|
| 114 |
+
bikelane_mag_model = mr.get_model("building_mag_hist_model", version = 2)
|
| 115 |
+
bikelane_mag_model_dir = bikelane_mag_model.download()
|
| 116 |
+
return joblib.load(bikelane_mag_model_dir + "/bikelane_mag_hist_model.pkl")
|
| 117 |
+
|
| 118 |
+
# Retrieving model
|
| 119 |
+
bikelane_mag_hist_model = get_bikelane_mag_model()
|
| 120 |
+
|
| 121 |
+
@st.cache_data()
|
| 122 |
+
def get_bikelane_rad_model(project=project):
|
| 123 |
+
mr = project.get_model_registry()
|
| 124 |
+
bikelane_rad_model = mr.get_model("bikelane_rad_hist_model", version = 2)
|
| 125 |
+
bikelane_rad_model_dir = bikelane_rad_model.download()
|
| 126 |
+
return joblib.load(bikelane_rad_model_dir + "/bikelane_rad_hist_model.pkl")
|
| 127 |
+
|
| 128 |
+
# Retrieving model
|
| 129 |
+
bikelane_rad_hist_model = get_bikelane_rad_model()
|
| 130 |
+
|
| 131 |
+
# Loading the feature group with latest data for bikelane
|
| 132 |
+
new_bikelane_fg = fs.get_feature_group(name = 'new_bikelane_fg', version = 1)
|
| 133 |
+
|
| 134 |
+
# Function to loading the feature group with latest data for bikelane as a dataset
|
| 135 |
+
@st.cache_data()
|
| 136 |
+
def retrieve_bikelane(feature_group=new_bikelane_fg):
|
| 137 |
+
new_bikelane_fg = feature_group.select_all()
|
| 138 |
+
df_bikelane_new = new_bikelane_fg.read(read_options={"use_hive": True})
|
| 139 |
+
return df_bikelane_new
|
| 140 |
+
|
| 141 |
+
# Retrieving bikelane data
|
| 142 |
+
bikelane_new = retrieve_bikelane()
|
| 143 |
+
|
| 144 |
+
# Making the predictions and getting the latest data for magnetic field data
|
| 145 |
+
bikelane_mag_prediction_data = bikelane_new[['time', 'x', 'y', 'z', 'temperature', 'et0_fao_evapotranspiration']]
|
| 146 |
+
bikelane_mag_prediction_data['et0_fao_evapotranspiration'] = bikelane_mag_prediction_data['et0_fao_evapotranspiration'].apply(fill_nan_with_zero)
|
| 147 |
+
bikelane_mag_most_recent_prediction = bikelane_mag_prediction_data[['x', 'y', 'z', 'temperature', 'et0_fao_evapotranspiration']]
|
| 148 |
+
bikelane_mag_most_recent_prediction = bikelane_mag_hist_model.predict(bikelane_mag_most_recent_prediction)
|
| 149 |
+
bikelane_mag_prediction_data['Status'] = bikelane_mag_most_recent_prediction
|
| 150 |
+
bikelane_mag_prediction_data['Status'].replace(['detection', 'no_detection'], ['Vehicle detected', 'No vehicle detected'], inplace=True)
|
| 151 |
+
bikelane_mag_prediction_data = bikelane_mag_prediction_data.rename(columns={'time': 'Time'})
|
| 152 |
+
bikelane_mag_prediction_data = bikelane_mag_prediction_data.set_index(['Time'])
|
| 153 |
+
st.dataframe(bikelane_mag_prediction_data[['Status']].tail(3))
|
| 154 |
+
|
| 155 |
+
# Making the predictions and getting the latest data for radar data
|
| 156 |
+
bikelane_rad_prediction_data = bikelane_new[['time', 'radar_0', 'radar_1', 'radar_2', 'radar_3', 'radar_4', 'radar_5', 'radar_6', 'radar_7', 'temperature', 'et0_fao_evapotranspiration']]
|
| 157 |
+
bikelane_rad_prediction_data['et0_fao_evapotranspiration'] = bikelane_rad_prediction_data['et0_fao_evapotranspiration'].apply(fill_nan_with_zero)
|
| 158 |
+
bikelane_rad_most_recent_prediction = bikelane_rad_prediction_data[['radar_0', 'radar_1', 'radar_2', 'radar_3', 'radar_4', 'radar_5', 'radar_6', 'radar_7', 'temperature', 'et0_fao_evapotranspiration']]
|
| 159 |
+
bikelane_rad_most_recent_prediction = bikelane_rad_hist_model.predict(bikelane_rad_most_recent_prediction)
|
| 160 |
+
bikelane_rad_prediction_data['Status'] = bikelane_rad_most_recent_prediction
|
| 161 |
+
bikelane_rad_prediction_data['Status'].replace(['detection', 'no_detection'], ['Vehicle detected', 'No vehicle detected'], inplace=True)
|
| 162 |
+
bikelane_rad_prediction_data = bikelane_rad_prediction_data.rename(columns={'time': 'Time'})
|
| 163 |
+
bikelane_rad_prediction_data = bikelane_rad_prediction_data.set_index(['Time'])
|
| 164 |
+
st.dataframe(bikelane_rad_prediction_data[['Status']].tail(3))
|
| 165 |
|
| 166 |
|
| 167 |
# Update button
|