# streamlit run edu_eload.py import streamlit as st import pandas as pd import numpy as np import joblib ### Helper functions MODEL_PATH = 'pipeline.pkl' def load_model(): return joblib.load(MODEL_PATH) def compute_prediction(building): prediction = model.predict(building) return prediction model = load_model() ### Input widgets and text elements st.title('Predict Hourly Electricity Load of Educational Builidngs') st.markdown('#') st.subheader('Building') square_feet = st.slider("square_feet", min_value=0, max_value=300000, value=272278) age = st.slider("age", min_value=0, max_value=100, value=60) st.markdown('#') st.subheader('Weather') air_temperature = st.slider("air_temperature", min_value=-20, max_value=50, value=14) precip_depth_1_hr = st.slider("precip_depth_1_hr", min_value=0.0, max_value=500.0, value=0.0) wind_speed = st.slider("wind_speed", min_value=0.0, max_value=20.0, value=4.0) st.markdown('#') st.subheader('Time') hour = st.slider("hour", min_value=0, max_value=23, value=12) weekday = st.selectbox("weekday", options=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], index=0) month = st.selectbox("month", options=["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], index=0) ### Compute prediction # Construct DF new_building = {} new_building['square_feet'] = square_feet new_building['air_temperature'] = air_temperature new_building['precip_depth_1_hr'] = precip_depth_1_hr new_building['wind_speed'] = wind_speed new_building['month'] = month new_building['weekday'] = weekday new_building['hour'] = hour new_building['age'] = age new_building_df = pd.DataFrame(new_building, index=[0]) # Call st.markdown('#') st.subheader('Predicted Hourly Electricity Load') prediciton = compute_prediction(new_building_df) st.markdown(f'**{prediciton[0]:.2f} kWh**')