Spaces:
Runtime error
Runtime error
bug fix
Browse files
app.py
CHANGED
@@ -111,10 +111,37 @@ def main():
|
|
111 |
# Start App
|
112 |
st.title("Temporal Fusion Transformers for Interpretable Multi-horizon Time Series Forecasting")
|
113 |
|
114 |
-
|
115 |
image = Image.open('data/image.png')
|
116 |
-
|
117 |
st.image(image, caption='Coding.Waterkant Festival for AI')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
st.markdown(body = """
|
119 |
### Abstract
|
120 |
Multi-horizon forecasting often contains a complex mix of inputs – including
|
@@ -141,37 +168,6 @@ def main():
|
|
141 |
Adjustments to the model and extention with Quantile forecast are coming soon ;)
|
142 |
""")
|
143 |
|
144 |
-
try:
|
145 |
-
# check if the key exists in session state
|
146 |
-
_ = st.session_state.rain
|
147 |
-
_ = st.session_state.temperature
|
148 |
-
_ = st.session_state.date
|
149 |
-
except AttributeError:
|
150 |
-
# otherwise set it to false
|
151 |
-
st.session_state.rain = 'Default'
|
152 |
-
st.session_state.temperature = 0.0
|
153 |
-
# st.session_state.date = datetime.date(2022, 10, 24)
|
154 |
-
|
155 |
-
RAIN_MAPPING = {
|
156 |
-
"Yes" : 1,
|
157 |
-
"No" : 0
|
158 |
-
}
|
159 |
-
|
160 |
-
parameters, df = load_data()
|
161 |
-
model = init_model()
|
162 |
-
|
163 |
-
dataloader = prepare_dataset(parameters, df.copy(), st.session_state.rain, st.session_state.temperature, st.session_state.date, RAIN_MAPPING)
|
164 |
-
preds = predict(model, dataloader, st.session_state.date)
|
165 |
-
|
166 |
-
data_plot = adjust_data_for_plot(df.copy(), preds)
|
167 |
-
fig, _ = generate_plot(data_plot)
|
168 |
-
datepicker = st.date_input("Start of Forecast", value = datetime.date(2022, 10, 24) ,min_value=datetime.date(2022, 6, 26) + datetime.timedelta(days = 35), max_value=datetime.date(2023, 6, 26) - datetime.timedelta(days = 30), key = "date")
|
169 |
-
|
170 |
-
st.pyplot(fig)
|
171 |
-
|
172 |
-
temperature = st.slider('Change in Temperature', min_value=-10.0, max_value=10.0, value=st.session_state.temperature, step=0.25, key = "temperature")
|
173 |
-
rain = st.radio("Rain Indicator", ('Default', 'Yes', 'No'), key = "rain")
|
174 |
-
|
175 |
if __name__ == '__main__':
|
176 |
main()
|
177 |
|
|
|
111 |
# Start App
|
112 |
st.title("Temporal Fusion Transformers for Interpretable Multi-horizon Time Series Forecasting")
|
113 |
|
|
|
114 |
image = Image.open('data/image.png')
|
|
|
115 |
st.image(image, caption='Coding.Waterkant Festival for AI')
|
116 |
+
|
117 |
+
st.markdown(body = """
|
118 |
+
### Experiments
|
119 |
+
We implemented TFT for sales multi-horizon sales forecast during Coding.Waterkant.
|
120 |
+
Please try our implementation and adjust some of the training data.
|
121 |
+
|
122 |
+
Adjustments to the model and extention with Quantile forecast are coming soon ;)
|
123 |
+
""")
|
124 |
+
|
125 |
+
RAIN_MAPPING = {
|
126 |
+
"Yes" : 1,
|
127 |
+
"No" : 0
|
128 |
+
}
|
129 |
+
|
130 |
+
parameters, df = load_data()
|
131 |
+
model = init_model()
|
132 |
+
|
133 |
+
datepicker = st.date_input("Start of Forecast", value = datetime.date(2022, 10, 24) ,min_value=datetime.date(2022, 6, 26) + datetime.timedelta(days = 35), max_value=datetime.date(2023, 6, 26) - datetime.timedelta(days = 30), key = "date")
|
134 |
+
temperature = st.slider('Change in Temperature', min_value=-10.0, max_value=10.0, value=0.0, step=0.25, key = "temperature")
|
135 |
+
rain = st.radio("Rain Indicator", ('Default', 'Yes', 'No'), key = "rain")
|
136 |
+
|
137 |
+
dataloader = prepare_dataset(parameters, df.copy(), st.session_state.rain, st.session_state.temperature, st.session_state.date, RAIN_MAPPING)
|
138 |
+
preds = predict(model, dataloader, st.session_state.date)
|
139 |
+
|
140 |
+
data_plot = adjust_data_for_plot(df.copy(), preds)
|
141 |
+
fig, _ = generate_plot(data_plot)
|
142 |
+
|
143 |
+
st.pyplot(fig)
|
144 |
+
|
145 |
st.markdown(body = """
|
146 |
### Abstract
|
147 |
Multi-horizon forecasting often contains a complex mix of inputs – including
|
|
|
168 |
Adjustments to the model and extention with Quantile forecast are coming soon ;)
|
169 |
""")
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
if __name__ == '__main__':
|
172 |
main()
|
173 |
|