Spaces:
Sleeping
Sleeping
Deleted empty folders
Browse files- HTM-related-code/Parameters/paramMultiStep.pyc +0 -0
- HTM-related-code/Parameters/paramMultiVar.pyc +0 -0
- HTM-related-code/Parameters/paramV3.pyc +0 -0
- HTM-related-code/nupic_anomaly_output.pyc +0 -0
- HTM-related-code/nupic_output_Multi.pyc +0 -0
- MQTT/nupic_output_MQTT.pyc +0 -0
- lstm_energy.ipynb +183 -19
- lstm_energy_01.keras +0 -0
HTM-related-code/Parameters/paramMultiStep.pyc
DELETED
Binary file (2.73 kB)
|
|
HTM-related-code/Parameters/paramMultiVar.pyc
DELETED
Binary file (2.75 kB)
|
|
HTM-related-code/Parameters/paramV3.pyc
DELETED
Binary file (2.57 kB)
|
|
HTM-related-code/nupic_anomaly_output.pyc
DELETED
Binary file (10.1 kB)
|
|
HTM-related-code/nupic_output_Multi.pyc
DELETED
Binary file (7.26 kB)
|
|
MQTT/nupic_output_MQTT.pyc
DELETED
Binary file (9.96 kB)
|
|
lstm_energy.ipynb
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
@@ -25,9 +25,115 @@
|
|
25 |
},
|
26 |
{
|
27 |
"cell_type": "code",
|
28 |
-
"execution_count":
|
29 |
"metadata": {},
|
30 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
"source": [
|
32 |
"# Prepar energy data set with extended features\n",
|
33 |
"feature_list = ['date', 'hvac_N', 'hvac_S', 'air_temp_set_1', 'solar_radiation_set_1']\n",
|
@@ -36,7 +142,7 @@
|
|
36 |
"extended_energy_data['date'] = pd.to_datetime(extended_energy_data['date'])\n",
|
37 |
"extended_energy_data.set_index('date', inplace=True)\n",
|
38 |
"\n",
|
39 |
-
"extended_energy_data = extended_energy_data.resample('
|
40 |
"# extended_energy_data = extended_energy_data.interpolate(method='linear')\n",
|
41 |
"\n",
|
42 |
"extended_energy_data = extended_energy_data.reset_index(drop=False)\n",
|
@@ -45,7 +151,7 @@
|
|
45 |
},
|
46 |
{
|
47 |
"cell_type": "code",
|
48 |
-
"execution_count":
|
49 |
"metadata": {},
|
50 |
"outputs": [],
|
51 |
"source": [
|
@@ -66,9 +172,20 @@
|
|
66 |
},
|
67 |
{
|
68 |
"cell_type": "code",
|
69 |
-
"execution_count":
|
70 |
"metadata": {},
|
71 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
"source": [
|
73 |
"testdataset_df = df_filtered[(df_filtered.date.dt.date <date(2019, 2, 20))]\n",
|
74 |
"\n",
|
@@ -84,7 +201,7 @@
|
|
84 |
},
|
85 |
{
|
86 |
"cell_type": "code",
|
87 |
-
"execution_count":
|
88 |
"metadata": {},
|
89 |
"outputs": [],
|
90 |
"source": [
|
@@ -101,15 +218,52 @@
|
|
101 |
},
|
102 |
{
|
103 |
"cell_type": "code",
|
104 |
-
"execution_count":
|
105 |
"metadata": {},
|
106 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
"source": [
|
108 |
"train,test = traindataset,testdataset\n",
|
109 |
-
"steps_in_past
|
110 |
-
"time_step
|
111 |
-
"no_inputs
|
112 |
-
"no_outputs
|
113 |
"def create_dataset(dataset,time_step):\n",
|
114 |
" x = [[] for _ in range(no_inputs)] \n",
|
115 |
" Y = [[] for _ in range(no_outputs)]\n",
|
@@ -202,9 +356,19 @@
|
|
202 |
},
|
203 |
{
|
204 |
"cell_type": "code",
|
205 |
-
"execution_count":
|
206 |
"metadata": {},
|
207 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
"source": [
|
209 |
"loss = model.evaluate(X_test, y_test)\n",
|
210 |
"test_predict1 = model.predict(X_test)\n",
|
@@ -217,7 +381,7 @@
|
|
217 |
},
|
218 |
{
|
219 |
"cell_type": "code",
|
220 |
-
"execution_count":
|
221 |
"metadata": {},
|
222 |
"outputs": [],
|
223 |
"source": [
|
@@ -229,8 +393,8 @@
|
|
229 |
"# Loop over the value index\n",
|
230 |
"for i, ax in enumerate(axes.flat):\n",
|
231 |
" # Plot your data or perform any other operations\n",
|
232 |
-
" ax.plot(
|
233 |
-
" ax.plot(
|
234 |
" # ax.set_title(f'Plot {i+1}')\n",
|
235 |
" ax.set_title('Testing Data - Predicted vs Actual')\n",
|
236 |
" ax.set_xlabel('Time [hours]')\n",
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 8,
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
|
|
25 |
},
|
26 |
{
|
27 |
"cell_type": "code",
|
28 |
+
"execution_count": 16,
|
29 |
"metadata": {},
|
30 |
+
"outputs": [
|
31 |
+
{
|
32 |
+
"name": "stderr",
|
33 |
+
"output_type": "stream",
|
34 |
+
"text": [
|
35 |
+
"C:\\Users\\levim\\AppData\\Local\\Temp\\ipykernel_12184\\1569659483.py:5: SettingWithCopyWarning: \n",
|
36 |
+
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
37 |
+
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
38 |
+
"\n",
|
39 |
+
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
40 |
+
" extended_energy_data['date'] = pd.to_datetime(extended_energy_data['date'])\n"
|
41 |
+
]
|
42 |
+
},
|
43 |
+
{
|
44 |
+
"data": {
|
45 |
+
"text/html": [
|
46 |
+
"<div>\n",
|
47 |
+
"<style scoped>\n",
|
48 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
49 |
+
" vertical-align: middle;\n",
|
50 |
+
" }\n",
|
51 |
+
"\n",
|
52 |
+
" .dataframe tbody tr th {\n",
|
53 |
+
" vertical-align: top;\n",
|
54 |
+
" }\n",
|
55 |
+
"\n",
|
56 |
+
" .dataframe thead th {\n",
|
57 |
+
" text-align: right;\n",
|
58 |
+
" }\n",
|
59 |
+
"</style>\n",
|
60 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
61 |
+
" <thead>\n",
|
62 |
+
" <tr style=\"text-align: right;\">\n",
|
63 |
+
" <th></th>\n",
|
64 |
+
" <th>date</th>\n",
|
65 |
+
" <th>hvac_N</th>\n",
|
66 |
+
" <th>hvac_S</th>\n",
|
67 |
+
" <th>air_temp_set_1</th>\n",
|
68 |
+
" <th>solar_radiation_set_1</th>\n",
|
69 |
+
" </tr>\n",
|
70 |
+
" </thead>\n",
|
71 |
+
" <tbody>\n",
|
72 |
+
" <tr>\n",
|
73 |
+
" <th>0</th>\n",
|
74 |
+
" <td>2018-01-01 00:00:00</td>\n",
|
75 |
+
" <td>NaN</td>\n",
|
76 |
+
" <td>NaN</td>\n",
|
77 |
+
" <td>11.5400</td>\n",
|
78 |
+
" <td>51.4075</td>\n",
|
79 |
+
" </tr>\n",
|
80 |
+
" <tr>\n",
|
81 |
+
" <th>1</th>\n",
|
82 |
+
" <td>2018-01-01 01:00:00</td>\n",
|
83 |
+
" <td>37.525001</td>\n",
|
84 |
+
" <td>19.395</td>\n",
|
85 |
+
" <td>10.8900</td>\n",
|
86 |
+
" <td>2.1250</td>\n",
|
87 |
+
" </tr>\n",
|
88 |
+
" <tr>\n",
|
89 |
+
" <th>2</th>\n",
|
90 |
+
" <td>2018-01-01 02:00:00</td>\n",
|
91 |
+
" <td>37.750001</td>\n",
|
92 |
+
" <td>22.775</td>\n",
|
93 |
+
" <td>10.7550</td>\n",
|
94 |
+
" <td>0.0000</td>\n",
|
95 |
+
" </tr>\n",
|
96 |
+
" <tr>\n",
|
97 |
+
" <th>3</th>\n",
|
98 |
+
" <td>2018-01-01 03:00:00</td>\n",
|
99 |
+
" <td>37.550001</td>\n",
|
100 |
+
" <td>18.920</td>\n",
|
101 |
+
" <td>10.4775</td>\n",
|
102 |
+
" <td>0.0000</td>\n",
|
103 |
+
" </tr>\n",
|
104 |
+
" <tr>\n",
|
105 |
+
" <th>4</th>\n",
|
106 |
+
" <td>2018-01-01 04:00:00</td>\n",
|
107 |
+
" <td>36.675001</td>\n",
|
108 |
+
" <td>21.600</td>\n",
|
109 |
+
" <td>9.9925</td>\n",
|
110 |
+
" <td>0.0000</td>\n",
|
111 |
+
" </tr>\n",
|
112 |
+
" </tbody>\n",
|
113 |
+
"</table>\n",
|
114 |
+
"</div>"
|
115 |
+
],
|
116 |
+
"text/plain": [
|
117 |
+
" date hvac_N hvac_S air_temp_set_1 \\\n",
|
118 |
+
"0 2018-01-01 00:00:00 NaN NaN 11.5400 \n",
|
119 |
+
"1 2018-01-01 01:00:00 37.525001 19.395 10.8900 \n",
|
120 |
+
"2 2018-01-01 02:00:00 37.750001 22.775 10.7550 \n",
|
121 |
+
"3 2018-01-01 03:00:00 37.550001 18.920 10.4775 \n",
|
122 |
+
"4 2018-01-01 04:00:00 36.675001 21.600 9.9925 \n",
|
123 |
+
"\n",
|
124 |
+
" solar_radiation_set_1 \n",
|
125 |
+
"0 51.4075 \n",
|
126 |
+
"1 2.1250 \n",
|
127 |
+
"2 0.0000 \n",
|
128 |
+
"3 0.0000 \n",
|
129 |
+
"4 0.0000 "
|
130 |
+
]
|
131 |
+
},
|
132 |
+
"execution_count": 16,
|
133 |
+
"metadata": {},
|
134 |
+
"output_type": "execute_result"
|
135 |
+
}
|
136 |
+
],
|
137 |
"source": [
|
138 |
"# Prepar energy data set with extended features\n",
|
139 |
"feature_list = ['date', 'hvac_N', 'hvac_S', 'air_temp_set_1', 'solar_radiation_set_1']\n",
|
|
|
142 |
"extended_energy_data['date'] = pd.to_datetime(extended_energy_data['date'])\n",
|
143 |
"extended_energy_data.set_index('date', inplace=True)\n",
|
144 |
"\n",
|
145 |
+
"extended_energy_data = extended_energy_data.resample('60T').mean()\n",
|
146 |
"# extended_energy_data = extended_energy_data.interpolate(method='linear')\n",
|
147 |
"\n",
|
148 |
"extended_energy_data = extended_energy_data.reset_index(drop=False)\n",
|
|
|
151 |
},
|
152 |
{
|
153 |
"cell_type": "code",
|
154 |
+
"execution_count": 17,
|
155 |
"metadata": {},
|
156 |
"outputs": [],
|
157 |
"source": [
|
|
|
172 |
},
|
173 |
{
|
174 |
"cell_type": "code",
|
175 |
+
"execution_count": 18,
|
176 |
"metadata": {},
|
177 |
+
"outputs": [
|
178 |
+
{
|
179 |
+
"data": {
|
180 |
+
"text/plain": [
|
181 |
+
"[]"
|
182 |
+
]
|
183 |
+
},
|
184 |
+
"execution_count": 18,
|
185 |
+
"metadata": {},
|
186 |
+
"output_type": "execute_result"
|
187 |
+
}
|
188 |
+
],
|
189 |
"source": [
|
190 |
"testdataset_df = df_filtered[(df_filtered.date.dt.date <date(2019, 2, 20))]\n",
|
191 |
"\n",
|
|
|
201 |
},
|
202 |
{
|
203 |
"cell_type": "code",
|
204 |
+
"execution_count": 19,
|
205 |
"metadata": {},
|
206 |
"outputs": [],
|
207 |
"source": [
|
|
|
218 |
},
|
219 |
{
|
220 |
"cell_type": "code",
|
221 |
+
"execution_count": 20,
|
222 |
"metadata": {},
|
223 |
+
"outputs": [
|
224 |
+
{
|
225 |
+
"name": "stdout",
|
226 |
+
"output_type": "stream",
|
227 |
+
"text": [
|
228 |
+
"Epoch 1/5\n",
|
229 |
+
"56/56 [==============================] - ETA: 0s - loss: 0.0359\n",
|
230 |
+
"Epoch 1: val_loss improved from inf to 0.02863, saving model to lstm_energy_01.keras\n",
|
231 |
+
"56/56 [==============================] - 14s 157ms/step - loss: 0.0359 - val_loss: 0.0286\n",
|
232 |
+
"Epoch 2/5\n",
|
233 |
+
"56/56 [==============================] - ETA: 0s - loss: 0.0185\n",
|
234 |
+
"Epoch 2: val_loss improved from 0.02863 to 0.02514, saving model to lstm_energy_01.keras\n",
|
235 |
+
"56/56 [==============================] - 8s 138ms/step - loss: 0.0185 - val_loss: 0.0251\n",
|
236 |
+
"Epoch 3/5\n",
|
237 |
+
"56/56 [==============================] - ETA: 0s - loss: 0.0170\n",
|
238 |
+
"Epoch 3: val_loss improved from 0.02514 to 0.02490, saving model to lstm_energy_01.keras\n",
|
239 |
+
"56/56 [==============================] - 8s 142ms/step - loss: 0.0170 - val_loss: 0.0249\n",
|
240 |
+
"Epoch 4/5\n",
|
241 |
+
"56/56 [==============================] - ETA: 0s - loss: 0.0159\n",
|
242 |
+
"Epoch 4: val_loss did not improve from 0.02490\n",
|
243 |
+
"56/56 [==============================] - 8s 141ms/step - loss: 0.0159 - val_loss: 0.0278\n",
|
244 |
+
"Epoch 5/5\n",
|
245 |
+
"56/56 [==============================] - ETA: 0s - loss: 0.0148\n",
|
246 |
+
"Epoch 5: val_loss did not improve from 0.02490\n",
|
247 |
+
"56/56 [==============================] - 9s 158ms/step - loss: 0.0148 - val_loss: 0.0255\n"
|
248 |
+
]
|
249 |
+
},
|
250 |
+
{
|
251 |
+
"data": {
|
252 |
+
"text/plain": [
|
253 |
+
"<keras.callbacks.History at 0x1e461cb04f0>"
|
254 |
+
]
|
255 |
+
},
|
256 |
+
"execution_count": 20,
|
257 |
+
"metadata": {},
|
258 |
+
"output_type": "execute_result"
|
259 |
+
}
|
260 |
+
],
|
261 |
"source": [
|
262 |
"train,test = traindataset,testdataset\n",
|
263 |
+
"steps_in_past = 3 \n",
|
264 |
+
"time_step = 24\n",
|
265 |
+
"no_inputs = 5\n",
|
266 |
+
"no_outputs = 2\n",
|
267 |
"def create_dataset(dataset,time_step):\n",
|
268 |
" x = [[] for _ in range(no_inputs)] \n",
|
269 |
" Y = [[] for _ in range(no_outputs)]\n",
|
|
|
356 |
},
|
357 |
{
|
358 |
"cell_type": "code",
|
359 |
+
"execution_count": 21,
|
360 |
"metadata": {},
|
361 |
+
"outputs": [
|
362 |
+
{
|
363 |
+
"name": "stdout",
|
364 |
+
"output_type": "stream",
|
365 |
+
"text": [
|
366 |
+
"18/18 [==============================] - 2s 32ms/step - loss: 0.0255\n",
|
367 |
+
"18/18 [==============================] - 2s 32ms/step\n",
|
368 |
+
"Loss: 0.02554473653435707\n"
|
369 |
+
]
|
370 |
+
}
|
371 |
+
],
|
372 |
"source": [
|
373 |
"loss = model.evaluate(X_test, y_test)\n",
|
374 |
"test_predict1 = model.predict(X_test)\n",
|
|
|
381 |
},
|
382 |
{
|
383 |
"cell_type": "code",
|
384 |
+
"execution_count": 22,
|
385 |
"metadata": {},
|
386 |
"outputs": [],
|
387 |
"source": [
|
|
|
393 |
"# Loop over the value index\n",
|
394 |
"for i, ax in enumerate(axes.flat):\n",
|
395 |
" # Plot your data or perform any other operations\n",
|
396 |
+
" ax.plot(y_test[i,0:time_step], label='Original Testing Data', color='blue')\n",
|
397 |
+
" ax.plot(test_predict1[i,0:time_step], label='Predicted Testing Data', color='red',alpha=0.8)\n",
|
398 |
" # ax.set_title(f'Plot {i+1}')\n",
|
399 |
" ax.set_title('Testing Data - Predicted vs Actual')\n",
|
400 |
" ax.set_xlabel('Time [hours]')\n",
|
lstm_energy_01.keras
ADDED
Binary file (568 kB). View file
|
|