File size: 1,914 Bytes
979adb5
 
 
 
 
 
 
 
 
 
 
 
e832612
979adb5
 
e832612
979adb5
 
e832612
979adb5
 
e832612
979adb5
 
 
 
 
 
 
 
e832612
979adb5
 
 
 
 
 
e832612
 
979adb5
 
e832612
 
 
 
 
 
 
 
 
 
 
 
 
979adb5
 
e832612
 
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
# 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**')