Spaces:
Running
Running
akshayballal
commited on
Commit
•
e3c6dcf
1
Parent(s):
8935117
Add LSTM code for VAV analysis
Browse files- physLSTM/full_lstm.ipynb +469 -108
- physLSTM/{lstm_vav.ipynb → lstm_vav_rtu1.ipynb} +287 -379
- physLSTM/lstm_vav_rtu2.ipynb +1075 -0
- physLSTM/lstm_vav_rtu3.ipynb +1131 -0
physLSTM/full_lstm.ipynb
CHANGED
@@ -43,9 +43,423 @@
|
|
43 |
},
|
44 |
{
|
45 |
"cell_type": "code",
|
46 |
-
"execution_count":
|
47 |
"metadata": {},
|
48 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
"source": [
|
50 |
"merged = pd.read_csv(r'../data/long_merge.csv')\n",
|
51 |
"\n",
|
@@ -70,7 +484,7 @@
|
|
70 |
},
|
71 |
{
|
72 |
"cell_type": "code",
|
73 |
-
"execution_count":
|
74 |
"metadata": {},
|
75 |
"outputs": [
|
76 |
{
|
@@ -207,7 +621,7 @@
|
|
207 |
"[2 rows x 23 columns]"
|
208 |
]
|
209 |
},
|
210 |
-
"execution_count":
|
211 |
"metadata": {},
|
212 |
"output_type": "execute_result"
|
213 |
}
|
@@ -230,7 +644,7 @@
|
|
230 |
},
|
231 |
{
|
232 |
"cell_type": "code",
|
233 |
-
"execution_count":
|
234 |
"metadata": {},
|
235 |
"outputs": [],
|
236 |
"source": [
|
@@ -245,7 +659,7 @@
|
|
245 |
},
|
246 |
{
|
247 |
"cell_type": "code",
|
248 |
-
"execution_count":
|
249 |
"metadata": {},
|
250 |
"outputs": [],
|
251 |
"source": [
|
@@ -267,7 +681,7 @@
|
|
267 |
},
|
268 |
{
|
269 |
"cell_type": "code",
|
270 |
-
"execution_count":
|
271 |
"metadata": {},
|
272 |
"outputs": [
|
273 |
{
|
@@ -276,7 +690,7 @@
|
|
276 |
"[]"
|
277 |
]
|
278 |
},
|
279 |
-
"execution_count":
|
280 |
"metadata": {},
|
281 |
"output_type": "execute_result"
|
282 |
}
|
@@ -297,7 +711,7 @@
|
|
297 |
},
|
298 |
{
|
299 |
"cell_type": "code",
|
300 |
-
"execution_count":
|
301 |
"metadata": {},
|
302 |
"outputs": [
|
303 |
{
|
@@ -306,7 +720,7 @@
|
|
306 |
"2072154"
|
307 |
]
|
308 |
},
|
309 |
-
"execution_count":
|
310 |
"metadata": {},
|
311 |
"output_type": "execute_result"
|
312 |
}
|
@@ -317,7 +731,7 @@
|
|
317 |
},
|
318 |
{
|
319 |
"cell_type": "code",
|
320 |
-
"execution_count":
|
321 |
"metadata": {},
|
322 |
"outputs": [
|
323 |
{
|
@@ -326,7 +740,7 @@
|
|
326 |
"(1157787, 909910)"
|
327 |
]
|
328 |
},
|
329 |
-
"execution_count":
|
330 |
"metadata": {},
|
331 |
"output_type": "execute_result"
|
332 |
}
|
@@ -337,7 +751,7 @@
|
|
337 |
},
|
338 |
{
|
339 |
"cell_type": "code",
|
340 |
-
"execution_count":
|
341 |
"metadata": {},
|
342 |
"outputs": [],
|
343 |
"source": [
|
@@ -351,102 +765,9 @@
|
|
351 |
},
|
352 |
{
|
353 |
"cell_type": "code",
|
354 |
-
"execution_count":
|
355 |
"metadata": {},
|
356 |
-
"outputs": [
|
357 |
-
{
|
358 |
-
"name": "stdout",
|
359 |
-
"output_type": "stream",
|
360 |
-
"text": [
|
361 |
-
"Epoch 1/5\n",
|
362 |
-
"9045/9045 [==============================] - ETA: 0s - loss: 0.0405\n",
|
363 |
-
"Epoch 1: val_loss improved from inf to 0.03129, saving model to lstm_smooth_01.tf\n",
|
364 |
-
"INFO:tensorflow:Assets written to: lstm_smooth_01.tf\\assets\n"
|
365 |
-
]
|
366 |
-
},
|
367 |
-
{
|
368 |
-
"name": "stderr",
|
369 |
-
"output_type": "stream",
|
370 |
-
"text": [
|
371 |
-
"INFO:tensorflow:Assets written to: lstm_smooth_01.tf\\assets\n"
|
372 |
-
]
|
373 |
-
},
|
374 |
-
{
|
375 |
-
"name": "stdout",
|
376 |
-
"output_type": "stream",
|
377 |
-
"text": [
|
378 |
-
"9045/9045 [==============================] - 346s 38ms/step - loss: 0.0405 - val_loss: 0.0313\n",
|
379 |
-
"Epoch 2/5\n",
|
380 |
-
"9045/9045 [==============================] - ETA: 0s - loss: 0.0228\n",
|
381 |
-
"Epoch 2: val_loss improved from 0.03129 to 0.02697, saving model to lstm_smooth_01.tf\n",
|
382 |
-
"INFO:tensorflow:Assets written to: lstm_smooth_01.tf\\assets\n"
|
383 |
-
]
|
384 |
-
},
|
385 |
-
{
|
386 |
-
"name": "stderr",
|
387 |
-
"output_type": "stream",
|
388 |
-
"text": [
|
389 |
-
"INFO:tensorflow:Assets written to: lstm_smooth_01.tf\\assets\n"
|
390 |
-
]
|
391 |
-
},
|
392 |
-
{
|
393 |
-
"name": "stdout",
|
394 |
-
"output_type": "stream",
|
395 |
-
"text": [
|
396 |
-
"9045/9045 [==============================] - 500s 55ms/step - loss: 0.0228 - val_loss: 0.0270\n",
|
397 |
-
"Epoch 3/5\n",
|
398 |
-
"9044/9045 [============================>.] - ETA: 0s - loss: 0.0211\n",
|
399 |
-
"Epoch 3: val_loss improved from 0.02697 to 0.02597, saving model to lstm_smooth_01.tf\n",
|
400 |
-
"INFO:tensorflow:Assets written to: lstm_smooth_01.tf\\assets\n"
|
401 |
-
]
|
402 |
-
},
|
403 |
-
{
|
404 |
-
"name": "stderr",
|
405 |
-
"output_type": "stream",
|
406 |
-
"text": [
|
407 |
-
"INFO:tensorflow:Assets written to: lstm_smooth_01.tf\\assets\n"
|
408 |
-
]
|
409 |
-
},
|
410 |
-
{
|
411 |
-
"name": "stdout",
|
412 |
-
"output_type": "stream",
|
413 |
-
"text": [
|
414 |
-
"9045/9045 [==============================] - 389s 43ms/step - loss: 0.0211 - val_loss: 0.0260\n",
|
415 |
-
"Epoch 4/5\n",
|
416 |
-
"9044/9045 [============================>.] - ETA: 0s - loss: 0.0203\n",
|
417 |
-
"Epoch 4: val_loss improved from 0.02597 to 0.02452, saving model to lstm_smooth_01.tf\n",
|
418 |
-
"INFO:tensorflow:Assets written to: lstm_smooth_01.tf\\assets\n"
|
419 |
-
]
|
420 |
-
},
|
421 |
-
{
|
422 |
-
"name": "stderr",
|
423 |
-
"output_type": "stream",
|
424 |
-
"text": [
|
425 |
-
"INFO:tensorflow:Assets written to: lstm_smooth_01.tf\\assets\n"
|
426 |
-
]
|
427 |
-
},
|
428 |
-
{
|
429 |
-
"name": "stdout",
|
430 |
-
"output_type": "stream",
|
431 |
-
"text": [
|
432 |
-
"9045/9045 [==============================] - 433s 48ms/step - loss: 0.0203 - val_loss: 0.0245\n",
|
433 |
-
"Epoch 5/5\n",
|
434 |
-
"9044/9045 [============================>.] - ETA: 0s - loss: 0.0198\n",
|
435 |
-
"Epoch 5: val_loss did not improve from 0.02452\n",
|
436 |
-
"9045/9045 [==============================] - 420s 46ms/step - loss: 0.0198 - val_loss: 0.0251\n"
|
437 |
-
]
|
438 |
-
},
|
439 |
-
{
|
440 |
-
"data": {
|
441 |
-
"text/plain": [
|
442 |
-
"<keras.src.callbacks.History at 0x1b4590f0250>"
|
443 |
-
]
|
444 |
-
},
|
445 |
-
"execution_count": 101,
|
446 |
-
"metadata": {},
|
447 |
-
"output_type": "execute_result"
|
448 |
-
}
|
449 |
-
],
|
450 |
"source": [
|
451 |
"train,test = traindataset,testdataset\n",
|
452 |
"\n",
|
@@ -480,6 +801,46 @@
|
|
480 |
"# model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=5, batch_size=128, verbose=1, callbacks=[checkpoint_callback])"
|
481 |
]
|
482 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
{
|
484 |
"cell_type": "code",
|
485 |
"execution_count": null,
|
|
|
43 |
},
|
44 |
{
|
45 |
"cell_type": "code",
|
46 |
+
"execution_count": 3,
|
47 |
"metadata": {},
|
48 |
+
"outputs": [
|
49 |
+
{
|
50 |
+
"data": {
|
51 |
+
"text/html": [
|
52 |
+
"<div>\n",
|
53 |
+
"<style scoped>\n",
|
54 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
55 |
+
" vertical-align: middle;\n",
|
56 |
+
" }\n",
|
57 |
+
"\n",
|
58 |
+
" .dataframe tbody tr th {\n",
|
59 |
+
" vertical-align: top;\n",
|
60 |
+
" }\n",
|
61 |
+
"\n",
|
62 |
+
" .dataframe thead th {\n",
|
63 |
+
" text-align: right;\n",
|
64 |
+
" }\n",
|
65 |
+
"</style>\n",
|
66 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
67 |
+
" <thead>\n",
|
68 |
+
" <tr style=\"text-align: right;\">\n",
|
69 |
+
" <th></th>\n",
|
70 |
+
" <th>date</th>\n",
|
71 |
+
" <th>zone_047_hw_valve</th>\n",
|
72 |
+
" <th>rtu_004_sat_sp_tn</th>\n",
|
73 |
+
" <th>zone_047_temp</th>\n",
|
74 |
+
" <th>zone_047_fan_spd</th>\n",
|
75 |
+
" <th>rtu_004_fltrd_sa_flow_tn</th>\n",
|
76 |
+
" <th>rtu_004_sa_temp</th>\n",
|
77 |
+
" <th>rtu_004_pa_static_stpt_tn</th>\n",
|
78 |
+
" <th>rtu_004_oa_flow_tn</th>\n",
|
79 |
+
" <th>rtu_004_oadmpr_pct</th>\n",
|
80 |
+
" <th>...</th>\n",
|
81 |
+
" <th>zone_047_heating_sp</th>\n",
|
82 |
+
" <th>Unnamed: 47_y</th>\n",
|
83 |
+
" <th>hvac_S</th>\n",
|
84 |
+
" <th>hp_hws_temp</th>\n",
|
85 |
+
" <th>aru_001_cwr_temp</th>\n",
|
86 |
+
" <th>aru_001_cws_fr_gpm</th>\n",
|
87 |
+
" <th>aru_001_cws_temp</th>\n",
|
88 |
+
" <th>aru_001_hwr_temp</th>\n",
|
89 |
+
" <th>aru_001_hws_fr_gpm</th>\n",
|
90 |
+
" <th>aru_001_hws_temp</th>\n",
|
91 |
+
" </tr>\n",
|
92 |
+
" </thead>\n",
|
93 |
+
" <tbody>\n",
|
94 |
+
" <tr>\n",
|
95 |
+
" <th>0</th>\n",
|
96 |
+
" <td>2018-01-01 00:00:00</td>\n",
|
97 |
+
" <td>100.0</td>\n",
|
98 |
+
" <td>69.0</td>\n",
|
99 |
+
" <td>67.5</td>\n",
|
100 |
+
" <td>20.0</td>\n",
|
101 |
+
" <td>9265.604</td>\n",
|
102 |
+
" <td>66.1</td>\n",
|
103 |
+
" <td>0.06</td>\n",
|
104 |
+
" <td>0.000000</td>\n",
|
105 |
+
" <td>28.0</td>\n",
|
106 |
+
" <td>...</td>\n",
|
107 |
+
" <td>NaN</td>\n",
|
108 |
+
" <td>NaN</td>\n",
|
109 |
+
" <td>NaN</td>\n",
|
110 |
+
" <td>75.3</td>\n",
|
111 |
+
" <td>NaN</td>\n",
|
112 |
+
" <td>NaN</td>\n",
|
113 |
+
" <td>NaN</td>\n",
|
114 |
+
" <td>NaN</td>\n",
|
115 |
+
" <td>NaN</td>\n",
|
116 |
+
" <td>NaN</td>\n",
|
117 |
+
" </tr>\n",
|
118 |
+
" <tr>\n",
|
119 |
+
" <th>1</th>\n",
|
120 |
+
" <td>2018-01-01 00:01:00</td>\n",
|
121 |
+
" <td>100.0</td>\n",
|
122 |
+
" <td>69.0</td>\n",
|
123 |
+
" <td>67.5</td>\n",
|
124 |
+
" <td>20.0</td>\n",
|
125 |
+
" <td>9265.604</td>\n",
|
126 |
+
" <td>66.0</td>\n",
|
127 |
+
" <td>0.06</td>\n",
|
128 |
+
" <td>6572.099162</td>\n",
|
129 |
+
" <td>28.0</td>\n",
|
130 |
+
" <td>...</td>\n",
|
131 |
+
" <td>NaN</td>\n",
|
132 |
+
" <td>NaN</td>\n",
|
133 |
+
" <td>NaN</td>\n",
|
134 |
+
" <td>75.3</td>\n",
|
135 |
+
" <td>NaN</td>\n",
|
136 |
+
" <td>NaN</td>\n",
|
137 |
+
" <td>NaN</td>\n",
|
138 |
+
" <td>NaN</td>\n",
|
139 |
+
" <td>NaN</td>\n",
|
140 |
+
" <td>NaN</td>\n",
|
141 |
+
" </tr>\n",
|
142 |
+
" <tr>\n",
|
143 |
+
" <th>2</th>\n",
|
144 |
+
" <td>2018-01-01 00:02:00</td>\n",
|
145 |
+
" <td>100.0</td>\n",
|
146 |
+
" <td>69.0</td>\n",
|
147 |
+
" <td>67.5</td>\n",
|
148 |
+
" <td>20.0</td>\n",
|
149 |
+
" <td>9708.240</td>\n",
|
150 |
+
" <td>66.1</td>\n",
|
151 |
+
" <td>0.06</td>\n",
|
152 |
+
" <td>7628.832542</td>\n",
|
153 |
+
" <td>28.0</td>\n",
|
154 |
+
" <td>...</td>\n",
|
155 |
+
" <td>NaN</td>\n",
|
156 |
+
" <td>NaN</td>\n",
|
157 |
+
" <td>NaN</td>\n",
|
158 |
+
" <td>75.3</td>\n",
|
159 |
+
" <td>NaN</td>\n",
|
160 |
+
" <td>NaN</td>\n",
|
161 |
+
" <td>NaN</td>\n",
|
162 |
+
" <td>NaN</td>\n",
|
163 |
+
" <td>NaN</td>\n",
|
164 |
+
" <td>NaN</td>\n",
|
165 |
+
" </tr>\n",
|
166 |
+
" <tr>\n",
|
167 |
+
" <th>3</th>\n",
|
168 |
+
" <td>2018-01-01 00:03:00</td>\n",
|
169 |
+
" <td>100.0</td>\n",
|
170 |
+
" <td>69.0</td>\n",
|
171 |
+
" <td>67.5</td>\n",
|
172 |
+
" <td>20.0</td>\n",
|
173 |
+
" <td>9611.638</td>\n",
|
174 |
+
" <td>66.1</td>\n",
|
175 |
+
" <td>0.06</td>\n",
|
176 |
+
" <td>7710.294617</td>\n",
|
177 |
+
" <td>28.0</td>\n",
|
178 |
+
" <td>...</td>\n",
|
179 |
+
" <td>NaN</td>\n",
|
180 |
+
" <td>NaN</td>\n",
|
181 |
+
" <td>NaN</td>\n",
|
182 |
+
" <td>75.3</td>\n",
|
183 |
+
" <td>NaN</td>\n",
|
184 |
+
" <td>NaN</td>\n",
|
185 |
+
" <td>NaN</td>\n",
|
186 |
+
" <td>NaN</td>\n",
|
187 |
+
" <td>NaN</td>\n",
|
188 |
+
" <td>NaN</td>\n",
|
189 |
+
" </tr>\n",
|
190 |
+
" <tr>\n",
|
191 |
+
" <th>4</th>\n",
|
192 |
+
" <td>2018-01-01 00:04:00</td>\n",
|
193 |
+
" <td>100.0</td>\n",
|
194 |
+
" <td>69.0</td>\n",
|
195 |
+
" <td>67.5</td>\n",
|
196 |
+
" <td>20.0</td>\n",
|
197 |
+
" <td>9215.110</td>\n",
|
198 |
+
" <td>66.0</td>\n",
|
199 |
+
" <td>0.06</td>\n",
|
200 |
+
" <td>7139.184090</td>\n",
|
201 |
+
" <td>28.0</td>\n",
|
202 |
+
" <td>...</td>\n",
|
203 |
+
" <td>NaN</td>\n",
|
204 |
+
" <td>NaN</td>\n",
|
205 |
+
" <td>NaN</td>\n",
|
206 |
+
" <td>75.3</td>\n",
|
207 |
+
" <td>NaN</td>\n",
|
208 |
+
" <td>NaN</td>\n",
|
209 |
+
" <td>NaN</td>\n",
|
210 |
+
" <td>NaN</td>\n",
|
211 |
+
" <td>NaN</td>\n",
|
212 |
+
" <td>NaN</td>\n",
|
213 |
+
" </tr>\n",
|
214 |
+
" <tr>\n",
|
215 |
+
" <th>...</th>\n",
|
216 |
+
" <td>...</td>\n",
|
217 |
+
" <td>...</td>\n",
|
218 |
+
" <td>...</td>\n",
|
219 |
+
" <td>...</td>\n",
|
220 |
+
" <td>...</td>\n",
|
221 |
+
" <td>...</td>\n",
|
222 |
+
" <td>...</td>\n",
|
223 |
+
" <td>...</td>\n",
|
224 |
+
" <td>...</td>\n",
|
225 |
+
" <td>...</td>\n",
|
226 |
+
" <td>...</td>\n",
|
227 |
+
" <td>...</td>\n",
|
228 |
+
" <td>...</td>\n",
|
229 |
+
" <td>...</td>\n",
|
230 |
+
" <td>...</td>\n",
|
231 |
+
" <td>...</td>\n",
|
232 |
+
" <td>...</td>\n",
|
233 |
+
" <td>...</td>\n",
|
234 |
+
" <td>...</td>\n",
|
235 |
+
" <td>...</td>\n",
|
236 |
+
" <td>...</td>\n",
|
237 |
+
" </tr>\n",
|
238 |
+
" <tr>\n",
|
239 |
+
" <th>2072149</th>\n",
|
240 |
+
" <td>2020-12-31 23:58:00</td>\n",
|
241 |
+
" <td>100.0</td>\n",
|
242 |
+
" <td>68.0</td>\n",
|
243 |
+
" <td>63.2</td>\n",
|
244 |
+
" <td>20.0</td>\n",
|
245 |
+
" <td>18884.834</td>\n",
|
246 |
+
" <td>64.4</td>\n",
|
247 |
+
" <td>0.06</td>\n",
|
248 |
+
" <td>2938.320000</td>\n",
|
249 |
+
" <td>23.4</td>\n",
|
250 |
+
" <td>...</td>\n",
|
251 |
+
" <td>71.0</td>\n",
|
252 |
+
" <td>69.0</td>\n",
|
253 |
+
" <td>23.145000</td>\n",
|
254 |
+
" <td>123.8</td>\n",
|
255 |
+
" <td>56.25</td>\n",
|
256 |
+
" <td>54.71</td>\n",
|
257 |
+
" <td>56.4</td>\n",
|
258 |
+
" <td>123.42</td>\n",
|
259 |
+
" <td>61.6</td>\n",
|
260 |
+
" <td>122.36</td>\n",
|
261 |
+
" </tr>\n",
|
262 |
+
" <tr>\n",
|
263 |
+
" <th>2072150</th>\n",
|
264 |
+
" <td>2020-12-31 23:58:00</td>\n",
|
265 |
+
" <td>100.0</td>\n",
|
266 |
+
" <td>68.0</td>\n",
|
267 |
+
" <td>63.2</td>\n",
|
268 |
+
" <td>20.0</td>\n",
|
269 |
+
" <td>18884.834</td>\n",
|
270 |
+
" <td>64.4</td>\n",
|
271 |
+
" <td>0.06</td>\n",
|
272 |
+
" <td>2938.320000</td>\n",
|
273 |
+
" <td>23.4</td>\n",
|
274 |
+
" <td>...</td>\n",
|
275 |
+
" <td>71.0</td>\n",
|
276 |
+
" <td>69.0</td>\n",
|
277 |
+
" <td>23.145000</td>\n",
|
278 |
+
" <td>123.8</td>\n",
|
279 |
+
" <td>56.25</td>\n",
|
280 |
+
" <td>54.71</td>\n",
|
281 |
+
" <td>56.4</td>\n",
|
282 |
+
" <td>123.42</td>\n",
|
283 |
+
" <td>61.6</td>\n",
|
284 |
+
" <td>122.36</td>\n",
|
285 |
+
" </tr>\n",
|
286 |
+
" <tr>\n",
|
287 |
+
" <th>2072151</th>\n",
|
288 |
+
" <td>2020-12-31 23:59:00</td>\n",
|
289 |
+
" <td>100.0</td>\n",
|
290 |
+
" <td>68.0</td>\n",
|
291 |
+
" <td>63.2</td>\n",
|
292 |
+
" <td>20.0</td>\n",
|
293 |
+
" <td>19345.508</td>\n",
|
294 |
+
" <td>64.3</td>\n",
|
295 |
+
" <td>0.06</td>\n",
|
296 |
+
" <td>3154.390000</td>\n",
|
297 |
+
" <td>23.4</td>\n",
|
298 |
+
" <td>...</td>\n",
|
299 |
+
" <td>71.0</td>\n",
|
300 |
+
" <td>69.0</td>\n",
|
301 |
+
" <td>23.145000</td>\n",
|
302 |
+
" <td>123.8</td>\n",
|
303 |
+
" <td>56.25</td>\n",
|
304 |
+
" <td>54.71</td>\n",
|
305 |
+
" <td>56.4</td>\n",
|
306 |
+
" <td>123.42</td>\n",
|
307 |
+
" <td>61.6</td>\n",
|
308 |
+
" <td>122.36</td>\n",
|
309 |
+
" </tr>\n",
|
310 |
+
" <tr>\n",
|
311 |
+
" <th>2072152</th>\n",
|
312 |
+
" <td>2020-12-31 23:59:00</td>\n",
|
313 |
+
" <td>100.0</td>\n",
|
314 |
+
" <td>68.0</td>\n",
|
315 |
+
" <td>63.2</td>\n",
|
316 |
+
" <td>20.0</td>\n",
|
317 |
+
" <td>19345.508</td>\n",
|
318 |
+
" <td>64.3</td>\n",
|
319 |
+
" <td>0.06</td>\n",
|
320 |
+
" <td>3154.390000</td>\n",
|
321 |
+
" <td>23.4</td>\n",
|
322 |
+
" <td>...</td>\n",
|
323 |
+
" <td>71.0</td>\n",
|
324 |
+
" <td>69.0</td>\n",
|
325 |
+
" <td>23.145000</td>\n",
|
326 |
+
" <td>123.8</td>\n",
|
327 |
+
" <td>56.25</td>\n",
|
328 |
+
" <td>54.71</td>\n",
|
329 |
+
" <td>56.4</td>\n",
|
330 |
+
" <td>123.42</td>\n",
|
331 |
+
" <td>61.6</td>\n",
|
332 |
+
" <td>122.36</td>\n",
|
333 |
+
" </tr>\n",
|
334 |
+
" <tr>\n",
|
335 |
+
" <th>2072153</th>\n",
|
336 |
+
" <td>2021-01-01 00:00:00</td>\n",
|
337 |
+
" <td>100.0</td>\n",
|
338 |
+
" <td>68.0</td>\n",
|
339 |
+
" <td>63.2</td>\n",
|
340 |
+
" <td>20.0</td>\n",
|
341 |
+
" <td>18650.232</td>\n",
|
342 |
+
" <td>64.1</td>\n",
|
343 |
+
" <td>0.06</td>\n",
|
344 |
+
" <td>3076.270000</td>\n",
|
345 |
+
" <td>22.9</td>\n",
|
346 |
+
" <td>...</td>\n",
|
347 |
+
" <td>71.0</td>\n",
|
348 |
+
" <td>69.0</td>\n",
|
349 |
+
" <td>23.788947</td>\n",
|
350 |
+
" <td>123.8</td>\n",
|
351 |
+
" <td>56.25</td>\n",
|
352 |
+
" <td>54.71</td>\n",
|
353 |
+
" <td>56.4</td>\n",
|
354 |
+
" <td>123.42</td>\n",
|
355 |
+
" <td>61.6</td>\n",
|
356 |
+
" <td>122.36</td>\n",
|
357 |
+
" </tr>\n",
|
358 |
+
" </tbody>\n",
|
359 |
+
"</table>\n",
|
360 |
+
"<p>2072154 rows × 30 columns</p>\n",
|
361 |
+
"</div>"
|
362 |
+
],
|
363 |
+
"text/plain": [
|
364 |
+
" date zone_047_hw_valve rtu_004_sat_sp_tn \\\n",
|
365 |
+
"0 2018-01-01 00:00:00 100.0 69.0 \n",
|
366 |
+
"1 2018-01-01 00:01:00 100.0 69.0 \n",
|
367 |
+
"2 2018-01-01 00:02:00 100.0 69.0 \n",
|
368 |
+
"3 2018-01-01 00:03:00 100.0 69.0 \n",
|
369 |
+
"4 2018-01-01 00:04:00 100.0 69.0 \n",
|
370 |
+
"... ... ... ... \n",
|
371 |
+
"2072149 2020-12-31 23:58:00 100.0 68.0 \n",
|
372 |
+
"2072150 2020-12-31 23:58:00 100.0 68.0 \n",
|
373 |
+
"2072151 2020-12-31 23:59:00 100.0 68.0 \n",
|
374 |
+
"2072152 2020-12-31 23:59:00 100.0 68.0 \n",
|
375 |
+
"2072153 2021-01-01 00:00:00 100.0 68.0 \n",
|
376 |
+
"\n",
|
377 |
+
" zone_047_temp zone_047_fan_spd rtu_004_fltrd_sa_flow_tn \\\n",
|
378 |
+
"0 67.5 20.0 9265.604 \n",
|
379 |
+
"1 67.5 20.0 9265.604 \n",
|
380 |
+
"2 67.5 20.0 9708.240 \n",
|
381 |
+
"3 67.5 20.0 9611.638 \n",
|
382 |
+
"4 67.5 20.0 9215.110 \n",
|
383 |
+
"... ... ... ... \n",
|
384 |
+
"2072149 63.2 20.0 18884.834 \n",
|
385 |
+
"2072150 63.2 20.0 18884.834 \n",
|
386 |
+
"2072151 63.2 20.0 19345.508 \n",
|
387 |
+
"2072152 63.2 20.0 19345.508 \n",
|
388 |
+
"2072153 63.2 20.0 18650.232 \n",
|
389 |
+
"\n",
|
390 |
+
" rtu_004_sa_temp rtu_004_pa_static_stpt_tn rtu_004_oa_flow_tn \\\n",
|
391 |
+
"0 66.1 0.06 0.000000 \n",
|
392 |
+
"1 66.0 0.06 6572.099162 \n",
|
393 |
+
"2 66.1 0.06 7628.832542 \n",
|
394 |
+
"3 66.1 0.06 7710.294617 \n",
|
395 |
+
"4 66.0 0.06 7139.184090 \n",
|
396 |
+
"... ... ... ... \n",
|
397 |
+
"2072149 64.4 0.06 2938.320000 \n",
|
398 |
+
"2072150 64.4 0.06 2938.320000 \n",
|
399 |
+
"2072151 64.3 0.06 3154.390000 \n",
|
400 |
+
"2072152 64.3 0.06 3154.390000 \n",
|
401 |
+
"2072153 64.1 0.06 3076.270000 \n",
|
402 |
+
"\n",
|
403 |
+
" rtu_004_oadmpr_pct ... zone_047_heating_sp Unnamed: 47_y \\\n",
|
404 |
+
"0 28.0 ... NaN NaN \n",
|
405 |
+
"1 28.0 ... NaN NaN \n",
|
406 |
+
"2 28.0 ... NaN NaN \n",
|
407 |
+
"3 28.0 ... NaN NaN \n",
|
408 |
+
"4 28.0 ... NaN NaN \n",
|
409 |
+
"... ... ... ... ... \n",
|
410 |
+
"2072149 23.4 ... 71.0 69.0 \n",
|
411 |
+
"2072150 23.4 ... 71.0 69.0 \n",
|
412 |
+
"2072151 23.4 ... 71.0 69.0 \n",
|
413 |
+
"2072152 23.4 ... 71.0 69.0 \n",
|
414 |
+
"2072153 22.9 ... 71.0 69.0 \n",
|
415 |
+
"\n",
|
416 |
+
" hvac_S hp_hws_temp aru_001_cwr_temp aru_001_cws_fr_gpm \\\n",
|
417 |
+
"0 NaN 75.3 NaN NaN \n",
|
418 |
+
"1 NaN 75.3 NaN NaN \n",
|
419 |
+
"2 NaN 75.3 NaN NaN \n",
|
420 |
+
"3 NaN 75.3 NaN NaN \n",
|
421 |
+
"4 NaN 75.3 NaN NaN \n",
|
422 |
+
"... ... ... ... ... \n",
|
423 |
+
"2072149 23.145000 123.8 56.25 54.71 \n",
|
424 |
+
"2072150 23.145000 123.8 56.25 54.71 \n",
|
425 |
+
"2072151 23.145000 123.8 56.25 54.71 \n",
|
426 |
+
"2072152 23.145000 123.8 56.25 54.71 \n",
|
427 |
+
"2072153 23.788947 123.8 56.25 54.71 \n",
|
428 |
+
"\n",
|
429 |
+
" aru_001_cws_temp aru_001_hwr_temp aru_001_hws_fr_gpm \\\n",
|
430 |
+
"0 NaN NaN NaN \n",
|
431 |
+
"1 NaN NaN NaN \n",
|
432 |
+
"2 NaN NaN NaN \n",
|
433 |
+
"3 NaN NaN NaN \n",
|
434 |
+
"4 NaN NaN NaN \n",
|
435 |
+
"... ... ... ... \n",
|
436 |
+
"2072149 56.4 123.42 61.6 \n",
|
437 |
+
"2072150 56.4 123.42 61.6 \n",
|
438 |
+
"2072151 56.4 123.42 61.6 \n",
|
439 |
+
"2072152 56.4 123.42 61.6 \n",
|
440 |
+
"2072153 56.4 123.42 61.6 \n",
|
441 |
+
"\n",
|
442 |
+
" aru_001_hws_temp \n",
|
443 |
+
"0 NaN \n",
|
444 |
+
"1 NaN \n",
|
445 |
+
"2 NaN \n",
|
446 |
+
"3 NaN \n",
|
447 |
+
"4 NaN \n",
|
448 |
+
"... ... \n",
|
449 |
+
"2072149 122.36 \n",
|
450 |
+
"2072150 122.36 \n",
|
451 |
+
"2072151 122.36 \n",
|
452 |
+
"2072152 122.36 \n",
|
453 |
+
"2072153 122.36 \n",
|
454 |
+
"\n",
|
455 |
+
"[2072154 rows x 30 columns]"
|
456 |
+
]
|
457 |
+
},
|
458 |
+
"execution_count": 3,
|
459 |
+
"metadata": {},
|
460 |
+
"output_type": "execute_result"
|
461 |
+
}
|
462 |
+
],
|
463 |
"source": [
|
464 |
"merged = pd.read_csv(r'../data/long_merge.csv')\n",
|
465 |
"\n",
|
|
|
484 |
},
|
485 |
{
|
486 |
"cell_type": "code",
|
487 |
+
"execution_count": 4,
|
488 |
"metadata": {},
|
489 |
"outputs": [
|
490 |
{
|
|
|
621 |
"[2 rows x 23 columns]"
|
622 |
]
|
623 |
},
|
624 |
+
"execution_count": 4,
|
625 |
"metadata": {},
|
626 |
"output_type": "execute_result"
|
627 |
}
|
|
|
644 |
},
|
645 |
{
|
646 |
"cell_type": "code",
|
647 |
+
"execution_count": 5,
|
648 |
"metadata": {},
|
649 |
"outputs": [],
|
650 |
"source": [
|
|
|
659 |
},
|
660 |
{
|
661 |
"cell_type": "code",
|
662 |
+
"execution_count": 6,
|
663 |
"metadata": {},
|
664 |
"outputs": [],
|
665 |
"source": [
|
|
|
681 |
},
|
682 |
{
|
683 |
"cell_type": "code",
|
684 |
+
"execution_count": 7,
|
685 |
"metadata": {},
|
686 |
"outputs": [
|
687 |
{
|
|
|
690 |
"[]"
|
691 |
]
|
692 |
},
|
693 |
+
"execution_count": 7,
|
694 |
"metadata": {},
|
695 |
"output_type": "execute_result"
|
696 |
}
|
|
|
711 |
},
|
712 |
{
|
713 |
"cell_type": "code",
|
714 |
+
"execution_count": 8,
|
715 |
"metadata": {},
|
716 |
"outputs": [
|
717 |
{
|
|
|
720 |
"2072154"
|
721 |
]
|
722 |
},
|
723 |
+
"execution_count": 8,
|
724 |
"metadata": {},
|
725 |
"output_type": "execute_result"
|
726 |
}
|
|
|
731 |
},
|
732 |
{
|
733 |
"cell_type": "code",
|
734 |
+
"execution_count": 9,
|
735 |
"metadata": {},
|
736 |
"outputs": [
|
737 |
{
|
|
|
740 |
"(1157787, 909910)"
|
741 |
]
|
742 |
},
|
743 |
+
"execution_count": 9,
|
744 |
"metadata": {},
|
745 |
"output_type": "execute_result"
|
746 |
}
|
|
|
751 |
},
|
752 |
{
|
753 |
"cell_type": "code",
|
754 |
+
"execution_count": 10,
|
755 |
"metadata": {},
|
756 |
"outputs": [],
|
757 |
"source": [
|
|
|
765 |
},
|
766 |
{
|
767 |
"cell_type": "code",
|
768 |
+
"execution_count": 11,
|
769 |
"metadata": {},
|
770 |
+
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
771 |
"source": [
|
772 |
"train,test = traindataset,testdataset\n",
|
773 |
"\n",
|
|
|
801 |
"# model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=5, batch_size=128, verbose=1, callbacks=[checkpoint_callback])"
|
802 |
]
|
803 |
},
|
804 |
+
{
|
805 |
+
"cell_type": "code",
|
806 |
+
"execution_count": 12,
|
807 |
+
"metadata": {},
|
808 |
+
"outputs": [
|
809 |
+
{
|
810 |
+
"data": {
|
811 |
+
"text/plain": [
|
812 |
+
"(1157756, 30, 15)"
|
813 |
+
]
|
814 |
+
},
|
815 |
+
"execution_count": 12,
|
816 |
+
"metadata": {},
|
817 |
+
"output_type": "execute_result"
|
818 |
+
}
|
819 |
+
],
|
820 |
+
"source": [
|
821 |
+
"X_train.shape"
|
822 |
+
]
|
823 |
+
},
|
824 |
+
{
|
825 |
+
"cell_type": "code",
|
826 |
+
"execution_count": 13,
|
827 |
+
"metadata": {},
|
828 |
+
"outputs": [
|
829 |
+
{
|
830 |
+
"data": {
|
831 |
+
"text/plain": [
|
832 |
+
"(1157756, 8)"
|
833 |
+
]
|
834 |
+
},
|
835 |
+
"execution_count": 13,
|
836 |
+
"metadata": {},
|
837 |
+
"output_type": "execute_result"
|
838 |
+
}
|
839 |
+
],
|
840 |
+
"source": [
|
841 |
+
"y_train.shape"
|
842 |
+
]
|
843 |
+
},
|
844 |
{
|
845 |
"cell_type": "code",
|
846 |
"execution_count": null,
|
physLSTM/{lstm_vav.ipynb → lstm_vav_rtu1.ipynb}
RENAMED
@@ -31,32 +31,11 @@
|
|
31 |
},
|
32 |
{
|
33 |
"cell_type": "code",
|
34 |
-
"execution_count":
|
35 |
"metadata": {},
|
36 |
-
"outputs": [
|
37 |
-
{
|
38 |
-
"ename": "MemoryError",
|
39 |
-
"evalue": "Unable to allocate 8.15 GiB for an array with shape (528, 2072154) and data type float64",
|
40 |
-
"output_type": "error",
|
41 |
-
"traceback": [
|
42 |
-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
43 |
-
"\u001b[1;31mMemoryError\u001b[0m Traceback (most recent call last)",
|
44 |
-
"Cell \u001b[1;32mIn[10], line 23\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[38;5;66;03m# for rtu in rtus:\u001b[39;00m\n\u001b[0;32m 15\u001b[0m \u001b[38;5;66;03m# for column in merged.columns:\u001b[39;00m\n\u001b[0;32m 16\u001b[0m \u001b[38;5;66;03m# if f\"rtu_00{rtu}_fltrd_sa\" in column:\u001b[39;00m\n\u001b[0;32m 17\u001b[0m \u001b[38;5;66;03m# cols.append(column)\u001b[39;00m\n\u001b[0;32m 18\u001b[0m cols \u001b[38;5;241m=\u001b[39m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdate\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m+\u001b[39m cols \u001b[38;5;241m+\u001b[39m [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mair_temp_set_1\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[0;32m 19\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mair_temp_set_2\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[0;32m 20\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdew_point_temperature_set_1d\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[0;32m 21\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mrelative_humidity_set_1\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[0;32m 22\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msolar_radiation_set_1\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m---> 23\u001b[0m input_dataset \u001b[38;5;241m=\u001b[39m \u001b[43mmerged\u001b[49m\u001b[43m[\u001b[49m\u001b[43mcols\u001b[49m\u001b[43m]\u001b[49m\n\u001b[0;32m 24\u001b[0m input_dataset\u001b[38;5;241m.\u001b[39mcolumns\n",
|
45 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\frame.py:4105\u001b[0m, in \u001b[0;36mDataFrame.__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 4102\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(indexer, \u001b[38;5;28mslice\u001b[39m):\n\u001b[0;32m 4103\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_slice(indexer, axis\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m)\n\u001b[1;32m-> 4105\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_take_with_is_copy\u001b[49m\u001b[43m(\u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 4107\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_single_key:\n\u001b[0;32m 4108\u001b[0m \u001b[38;5;66;03m# What does looking for a single key in a non-unique index return?\u001b[39;00m\n\u001b[0;32m 4109\u001b[0m \u001b[38;5;66;03m# The behavior is inconsistent. It returns a Series, except when\u001b[39;00m\n\u001b[0;32m 4110\u001b[0m \u001b[38;5;66;03m# - the key itself is repeated (test on data.shape, #9519), or\u001b[39;00m\n\u001b[0;32m 4111\u001b[0m \u001b[38;5;66;03m# - we have a MultiIndex on columns (test on self.columns, #21309)\u001b[39;00m\n\u001b[0;32m 4112\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m data\u001b[38;5;241m.\u001b[39mshape[\u001b[38;5;241m1\u001b[39m] \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m1\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcolumns, MultiIndex):\n\u001b[0;32m 4113\u001b[0m \u001b[38;5;66;03m# GH#26490 using data[key] can cause RecursionError\u001b[39;00m\n",
|
46 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\generic.py:4150\u001b[0m, in \u001b[0;36mNDFrame._take_with_is_copy\u001b[1;34m(self, indices, axis)\u001b[0m\n\u001b[0;32m 4139\u001b[0m \u001b[38;5;129m@final\u001b[39m\n\u001b[0;32m 4140\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_take_with_is_copy\u001b[39m(\u001b[38;5;28mself\u001b[39m, indices, axis: Axis \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Self:\n\u001b[0;32m 4141\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 4142\u001b[0m \u001b[38;5;124;03m Internal version of the `take` method that sets the `_is_copy`\u001b[39;00m\n\u001b[0;32m 4143\u001b[0m \u001b[38;5;124;03m attribute to keep track of the parent dataframe (using in indexing\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 4148\u001b[0m \u001b[38;5;124;03m See the docstring of `take` for full explanation of the parameters.\u001b[39;00m\n\u001b[0;32m 4149\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m-> 4150\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtake\u001b[49m\u001b[43m(\u001b[49m\u001b[43mindices\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindices\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43maxis\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 4151\u001b[0m \u001b[38;5;66;03m# Maybe set copy if we didn't actually change the index.\u001b[39;00m\n\u001b[0;32m 4152\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mndim \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m2\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m result\u001b[38;5;241m.\u001b[39m_get_axis(axis)\u001b[38;5;241m.\u001b[39mequals(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_axis(axis)):\n",
|
47 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\generic.py:4130\u001b[0m, in \u001b[0;36mNDFrame.take\u001b[1;34m(self, indices, axis, **kwargs)\u001b[0m\n\u001b[0;32m 4125\u001b[0m \u001b[38;5;66;03m# We can get here with a slice via DataFrame.__getitem__\u001b[39;00m\n\u001b[0;32m 4126\u001b[0m indices \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39marange(\n\u001b[0;32m 4127\u001b[0m indices\u001b[38;5;241m.\u001b[39mstart, indices\u001b[38;5;241m.\u001b[39mstop, indices\u001b[38;5;241m.\u001b[39mstep, dtype\u001b[38;5;241m=\u001b[39mnp\u001b[38;5;241m.\u001b[39mintp\n\u001b[0;32m 4128\u001b[0m )\n\u001b[1;32m-> 4130\u001b[0m new_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_mgr\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtake\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 4131\u001b[0m \u001b[43m \u001b[49m\u001b[43mindices\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 4132\u001b[0m \u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_block_manager_axis\u001b[49m\u001b[43m(\u001b[49m\u001b[43maxis\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 4133\u001b[0m \u001b[43m \u001b[49m\u001b[43mverify\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[0;32m 4134\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 4135\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_constructor_from_mgr(new_data, axes\u001b[38;5;241m=\u001b[39mnew_data\u001b[38;5;241m.\u001b[39maxes)\u001b[38;5;241m.\u001b[39m__finalize__(\n\u001b[0;32m 4136\u001b[0m \u001b[38;5;28mself\u001b[39m, method\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtake\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 4137\u001b[0m )\n",
|
48 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\internals\\managers.py:894\u001b[0m, in \u001b[0;36mBaseBlockManager.take\u001b[1;34m(self, indexer, axis, verify)\u001b[0m\n\u001b[0;32m 891\u001b[0m indexer \u001b[38;5;241m=\u001b[39m maybe_convert_indices(indexer, n, verify\u001b[38;5;241m=\u001b[39mverify)\n\u001b[0;32m 893\u001b[0m new_labels \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maxes[axis]\u001b[38;5;241m.\u001b[39mtake(indexer)\n\u001b[1;32m--> 894\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreindex_indexer\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 895\u001b[0m \u001b[43m \u001b[49m\u001b[43mnew_axis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnew_labels\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 896\u001b[0m \u001b[43m \u001b[49m\u001b[43mindexer\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 897\u001b[0m \u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43maxis\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 898\u001b[0m \u001b[43m \u001b[49m\u001b[43mallow_dups\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[0;32m 899\u001b[0m \u001b[43m \u001b[49m\u001b[43mcopy\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[0;32m 900\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
|
49 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\internals\\managers.py:680\u001b[0m, in \u001b[0;36mBaseBlockManager.reindex_indexer\u001b[1;34m(self, new_axis, indexer, axis, fill_value, allow_dups, copy, only_slice, use_na_proxy)\u001b[0m\n\u001b[0;32m 677\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mIndexError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRequested axis not found in manager\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 679\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m axis \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m--> 680\u001b[0m new_blocks \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_slice_take_blocks_ax0\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 681\u001b[0m \u001b[43m \u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 682\u001b[0m \u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfill_value\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 683\u001b[0m \u001b[43m \u001b[49m\u001b[43monly_slice\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43monly_slice\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 684\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_na_proxy\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43muse_na_proxy\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 685\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 686\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 687\u001b[0m new_blocks \u001b[38;5;241m=\u001b[39m [\n\u001b[0;32m 688\u001b[0m blk\u001b[38;5;241m.\u001b[39mtake_nd(\n\u001b[0;32m 689\u001b[0m indexer,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 695\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m blk \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mblocks\n\u001b[0;32m 696\u001b[0m ]\n",
|
50 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\internals\\managers.py:843\u001b[0m, in \u001b[0;36mBaseBlockManager._slice_take_blocks_ax0\u001b[1;34m(self, slice_or_indexer, fill_value, only_slice, use_na_proxy, ref_inplace_op)\u001b[0m\n\u001b[0;32m 841\u001b[0m blocks\u001b[38;5;241m.\u001b[39mappend(nb)\n\u001b[0;32m 842\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 843\u001b[0m nb \u001b[38;5;241m=\u001b[39m \u001b[43mblk\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtake_nd\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtaker\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnew_mgr_locs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmgr_locs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 844\u001b[0m blocks\u001b[38;5;241m.\u001b[39mappend(nb)\n\u001b[0;32m 846\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m blocks\n",
|
51 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\internals\\blocks.py:1307\u001b[0m, in \u001b[0;36mBlock.take_nd\u001b[1;34m(self, indexer, axis, new_mgr_locs, fill_value)\u001b[0m\n\u001b[0;32m 1304\u001b[0m allow_fill \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m 1306\u001b[0m \u001b[38;5;66;03m# Note: algos.take_nd has upcast logic similar to coerce_to_target_dtype\u001b[39;00m\n\u001b[1;32m-> 1307\u001b[0m new_values \u001b[38;5;241m=\u001b[39m \u001b[43malgos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtake_nd\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 1308\u001b[0m \u001b[43m \u001b[49m\u001b[43mvalues\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43maxis\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mallow_fill\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mallow_fill\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfill_value\u001b[49m\n\u001b[0;32m 1309\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1311\u001b[0m \u001b[38;5;66;03m# Called from three places in managers, all of which satisfy\u001b[39;00m\n\u001b[0;32m 1312\u001b[0m \u001b[38;5;66;03m# these assertions\u001b[39;00m\n\u001b[0;32m 1313\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(\u001b[38;5;28mself\u001b[39m, ExtensionBlock):\n\u001b[0;32m 1314\u001b[0m \u001b[38;5;66;03m# NB: in this case, the 'axis' kwarg will be ignored in the\u001b[39;00m\n\u001b[0;32m 1315\u001b[0m \u001b[38;5;66;03m# algos.take_nd call above.\u001b[39;00m\n",
|
52 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\array_algos\\take.py:117\u001b[0m, in \u001b[0;36mtake_nd\u001b[1;34m(arr, indexer, axis, fill_value, allow_fill)\u001b[0m\n\u001b[0;32m 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m arr\u001b[38;5;241m.\u001b[39mtake(indexer, fill_value\u001b[38;5;241m=\u001b[39mfill_value, allow_fill\u001b[38;5;241m=\u001b[39mallow_fill)\n\u001b[0;32m 116\u001b[0m arr \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39masarray(arr)\n\u001b[1;32m--> 117\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_take_nd_ndarray\u001b[49m\u001b[43m(\u001b[49m\u001b[43marr\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mallow_fill\u001b[49m\u001b[43m)\u001b[49m\n",
|
53 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\array_algos\\take.py:157\u001b[0m, in \u001b[0;36m_take_nd_ndarray\u001b[1;34m(arr, indexer, axis, fill_value, allow_fill)\u001b[0m\n\u001b[0;32m 155\u001b[0m out \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mempty(out_shape, dtype\u001b[38;5;241m=\u001b[39mdtype, order\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mF\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 156\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 157\u001b[0m out \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mempty(out_shape, dtype\u001b[38;5;241m=\u001b[39mdtype)\n\u001b[0;32m 159\u001b[0m func \u001b[38;5;241m=\u001b[39m _get_take_nd_function(\n\u001b[0;32m 160\u001b[0m arr\u001b[38;5;241m.\u001b[39mndim, arr\u001b[38;5;241m.\u001b[39mdtype, out\u001b[38;5;241m.\u001b[39mdtype, axis\u001b[38;5;241m=\u001b[39maxis, mask_info\u001b[38;5;241m=\u001b[39mmask_info\n\u001b[0;32m 161\u001b[0m )\n\u001b[0;32m 162\u001b[0m func(arr, indexer, out, fill_value)\n",
|
54 |
-
"\u001b[1;31mMemoryError\u001b[0m: Unable to allocate 8.15 GiB for an array with shape (528, 2072154) and data type float64"
|
55 |
-
]
|
56 |
-
}
|
57 |
-
],
|
58 |
"source": [
|
59 |
-
"zones = [69, 68,67, 66,65
|
60 |
"rtus = [1]\n",
|
61 |
"cols = []\n",
|
62 |
"\n",
|
@@ -67,8 +46,9 @@
|
|
67 |
"\n",
|
68 |
"for zone in zones:\n",
|
69 |
" for column in merged.columns:\n",
|
70 |
-
" if f\"zone_0{zone}\" in column
|
71 |
-
"
|
|
|
72 |
"# for rtu in rtus:\n",
|
73 |
"# for column in merged.columns:\n",
|
74 |
"# if f\"rtu_00{rtu}_fltrd_sa\" in column:\n",
|
@@ -83,14 +63,14 @@
|
|
83 |
},
|
84 |
{
|
85 |
"cell_type": "code",
|
86 |
-
"execution_count":
|
87 |
"metadata": {},
|
88 |
"outputs": [
|
89 |
{
|
90 |
"name": "stderr",
|
91 |
"output_type": "stream",
|
92 |
"text": [
|
93 |
-
"C:\\Users\\arbal\\AppData\\Local\\Temp\\
|
94 |
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
95 |
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
96 |
"\n",
|
@@ -99,24 +79,10 @@
|
|
99 |
]
|
100 |
},
|
101 |
{
|
102 |
-
"
|
103 |
-
"
|
104 |
-
"
|
105 |
-
|
106 |
-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
107 |
-
"\u001b[1;31mMemoryError\u001b[0m Traceback (most recent call last)",
|
108 |
-
"Cell \u001b[1;32mIn[11], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m input_dataset[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdate\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mto_datetime(input_dataset[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdate\u001b[39m\u001b[38;5;124m'\u001b[39m], \u001b[38;5;28mformat\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mY-\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mm-\u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[38;5;124m \u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mH:\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mM:\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mS\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m----> 2\u001b[0m df_filtered \u001b[38;5;241m=\u001b[39m \u001b[43minput_dataset\u001b[49m\u001b[43m[\u001b[49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43minput_dataset\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdate\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdt\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdate\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m>\u001b[39;49m\u001b[43mdate\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m2018\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m&\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43minput_dataset\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdate\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdt\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdate\u001b[49m\u001b[38;5;241;43m<\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mdate\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m2021\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m df_filtered\u001b[38;5;241m.\u001b[39misna()\u001b[38;5;241m.\u001b[39many()\u001b[38;5;241m.\u001b[39many():\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThere are NA values in the DataFrame columns.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
|
109 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\frame.py:4081\u001b[0m, in \u001b[0;36mDataFrame.__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 4079\u001b[0m \u001b[38;5;66;03m# Do we have a (boolean) 1d indexer?\u001b[39;00m\n\u001b[0;32m 4080\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m com\u001b[38;5;241m.\u001b[39mis_bool_indexer(key):\n\u001b[1;32m-> 4081\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_getitem_bool_array\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 4083\u001b[0m \u001b[38;5;66;03m# We are left with two options: a single key, and a collection of keys,\u001b[39;00m\n\u001b[0;32m 4084\u001b[0m \u001b[38;5;66;03m# We interpret tuples as collections only for non-MultiIndex\u001b[39;00m\n\u001b[0;32m 4085\u001b[0m is_single_key \u001b[38;5;241m=\u001b[39m \u001b[38;5;28misinstance\u001b[39m(key, \u001b[38;5;28mtuple\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m is_list_like(key)\n",
|
110 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\frame.py:4143\u001b[0m, in \u001b[0;36mDataFrame._getitem_bool_array\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 4140\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcopy(deep\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[0;32m 4142\u001b[0m indexer \u001b[38;5;241m=\u001b[39m key\u001b[38;5;241m.\u001b[39mnonzero()[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m-> 4143\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_take_with_is_copy\u001b[49m\u001b[43m(\u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m)\u001b[49m\n",
|
111 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\generic.py:4150\u001b[0m, in \u001b[0;36mNDFrame._take_with_is_copy\u001b[1;34m(self, indices, axis)\u001b[0m\n\u001b[0;32m 4139\u001b[0m \u001b[38;5;129m@final\u001b[39m\n\u001b[0;32m 4140\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_take_with_is_copy\u001b[39m(\u001b[38;5;28mself\u001b[39m, indices, axis: Axis \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Self:\n\u001b[0;32m 4141\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 4142\u001b[0m \u001b[38;5;124;03m Internal version of the `take` method that sets the `_is_copy`\u001b[39;00m\n\u001b[0;32m 4143\u001b[0m \u001b[38;5;124;03m attribute to keep track of the parent dataframe (using in indexing\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 4148\u001b[0m \u001b[38;5;124;03m See the docstring of `take` for full explanation of the parameters.\u001b[39;00m\n\u001b[0;32m 4149\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m-> 4150\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtake\u001b[49m\u001b[43m(\u001b[49m\u001b[43mindices\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindices\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43maxis\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 4151\u001b[0m \u001b[38;5;66;03m# Maybe set copy if we didn't actually change the index.\u001b[39;00m\n\u001b[0;32m 4152\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mndim \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m2\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m result\u001b[38;5;241m.\u001b[39m_get_axis(axis)\u001b[38;5;241m.\u001b[39mequals(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_axis(axis)):\n",
|
112 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\generic.py:4130\u001b[0m, in \u001b[0;36mNDFrame.take\u001b[1;34m(self, indices, axis, **kwargs)\u001b[0m\n\u001b[0;32m 4125\u001b[0m \u001b[38;5;66;03m# We can get here with a slice via DataFrame.__getitem__\u001b[39;00m\n\u001b[0;32m 4126\u001b[0m indices \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39marange(\n\u001b[0;32m 4127\u001b[0m indices\u001b[38;5;241m.\u001b[39mstart, indices\u001b[38;5;241m.\u001b[39mstop, indices\u001b[38;5;241m.\u001b[39mstep, dtype\u001b[38;5;241m=\u001b[39mnp\u001b[38;5;241m.\u001b[39mintp\n\u001b[0;32m 4128\u001b[0m )\n\u001b[1;32m-> 4130\u001b[0m new_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_mgr\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtake\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 4131\u001b[0m \u001b[43m \u001b[49m\u001b[43mindices\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 4132\u001b[0m \u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_block_manager_axis\u001b[49m\u001b[43m(\u001b[49m\u001b[43maxis\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 4133\u001b[0m \u001b[43m \u001b[49m\u001b[43mverify\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[0;32m 4134\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 4135\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_constructor_from_mgr(new_data, axes\u001b[38;5;241m=\u001b[39mnew_data\u001b[38;5;241m.\u001b[39maxes)\u001b[38;5;241m.\u001b[39m__finalize__(\n\u001b[0;32m 4136\u001b[0m \u001b[38;5;28mself\u001b[39m, method\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtake\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 4137\u001b[0m )\n",
|
113 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\internals\\managers.py:894\u001b[0m, in \u001b[0;36mBaseBlockManager.take\u001b[1;34m(self, indexer, axis, verify)\u001b[0m\n\u001b[0;32m 891\u001b[0m indexer \u001b[38;5;241m=\u001b[39m maybe_convert_indices(indexer, n, verify\u001b[38;5;241m=\u001b[39mverify)\n\u001b[0;32m 893\u001b[0m new_labels \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maxes[axis]\u001b[38;5;241m.\u001b[39mtake(indexer)\n\u001b[1;32m--> 894\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreindex_indexer\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 895\u001b[0m \u001b[43m \u001b[49m\u001b[43mnew_axis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnew_labels\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 896\u001b[0m \u001b[43m \u001b[49m\u001b[43mindexer\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 897\u001b[0m \u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43maxis\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 898\u001b[0m \u001b[43m \u001b[49m\u001b[43mallow_dups\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[0;32m 899\u001b[0m \u001b[43m \u001b[49m\u001b[43mcopy\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[0;32m 900\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
|
114 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\internals\\managers.py:687\u001b[0m, in \u001b[0;36mBaseBlockManager.reindex_indexer\u001b[1;34m(self, new_axis, indexer, axis, fill_value, allow_dups, copy, only_slice, use_na_proxy)\u001b[0m\n\u001b[0;32m 680\u001b[0m new_blocks \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_slice_take_blocks_ax0(\n\u001b[0;32m 681\u001b[0m indexer,\n\u001b[0;32m 682\u001b[0m fill_value\u001b[38;5;241m=\u001b[39mfill_value,\n\u001b[0;32m 683\u001b[0m only_slice\u001b[38;5;241m=\u001b[39monly_slice,\n\u001b[0;32m 684\u001b[0m use_na_proxy\u001b[38;5;241m=\u001b[39muse_na_proxy,\n\u001b[0;32m 685\u001b[0m )\n\u001b[0;32m 686\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 687\u001b[0m new_blocks \u001b[38;5;241m=\u001b[39m \u001b[43m[\u001b[49m\n\u001b[0;32m 688\u001b[0m \u001b[43m \u001b[49m\u001b[43mblk\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtake_nd\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 689\u001b[0m \u001b[43m \u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 690\u001b[0m \u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[0;32m 691\u001b[0m \u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\n\u001b[0;32m 692\u001b[0m \u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mis\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mnot\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mblk\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfill_value\u001b[49m\n\u001b[0;32m 693\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 694\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 695\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mblk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mblocks\u001b[49m\n\u001b[0;32m 696\u001b[0m \u001b[43m \u001b[49m\u001b[43m]\u001b[49m\n\u001b[0;32m 698\u001b[0m new_axes \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maxes)\n\u001b[0;32m 699\u001b[0m new_axes[axis] \u001b[38;5;241m=\u001b[39m new_axis\n",
|
115 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\internals\\managers.py:688\u001b[0m, in \u001b[0;36m<listcomp>\u001b[1;34m(.0)\u001b[0m\n\u001b[0;32m 680\u001b[0m new_blocks \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_slice_take_blocks_ax0(\n\u001b[0;32m 681\u001b[0m indexer,\n\u001b[0;32m 682\u001b[0m fill_value\u001b[38;5;241m=\u001b[39mfill_value,\n\u001b[0;32m 683\u001b[0m only_slice\u001b[38;5;241m=\u001b[39monly_slice,\n\u001b[0;32m 684\u001b[0m use_na_proxy\u001b[38;5;241m=\u001b[39muse_na_proxy,\n\u001b[0;32m 685\u001b[0m )\n\u001b[0;32m 686\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 687\u001b[0m new_blocks \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m--> 688\u001b[0m \u001b[43mblk\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtake_nd\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 689\u001b[0m \u001b[43m \u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 690\u001b[0m \u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[0;32m 691\u001b[0m \u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\n\u001b[0;32m 692\u001b[0m \u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mis\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mnot\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mblk\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfill_value\u001b[49m\n\u001b[0;32m 693\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 694\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 695\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m blk \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mblocks\n\u001b[0;32m 696\u001b[0m ]\n\u001b[0;32m 698\u001b[0m new_axes \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maxes)\n\u001b[0;32m 699\u001b[0m new_axes[axis] \u001b[38;5;241m=\u001b[39m new_axis\n",
|
116 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\internals\\blocks.py:1307\u001b[0m, in \u001b[0;36mBlock.take_nd\u001b[1;34m(self, indexer, axis, new_mgr_locs, fill_value)\u001b[0m\n\u001b[0;32m 1304\u001b[0m allow_fill \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m 1306\u001b[0m \u001b[38;5;66;03m# Note: algos.take_nd has upcast logic similar to coerce_to_target_dtype\u001b[39;00m\n\u001b[1;32m-> 1307\u001b[0m new_values \u001b[38;5;241m=\u001b[39m \u001b[43malgos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtake_nd\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 1308\u001b[0m \u001b[43m \u001b[49m\u001b[43mvalues\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43maxis\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mallow_fill\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mallow_fill\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfill_value\u001b[49m\n\u001b[0;32m 1309\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1311\u001b[0m \u001b[38;5;66;03m# Called from three places in managers, all of which satisfy\u001b[39;00m\n\u001b[0;32m 1312\u001b[0m \u001b[38;5;66;03m# these assertions\u001b[39;00m\n\u001b[0;32m 1313\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(\u001b[38;5;28mself\u001b[39m, ExtensionBlock):\n\u001b[0;32m 1314\u001b[0m \u001b[38;5;66;03m# NB: in this case, the 'axis' kwarg will be ignored in the\u001b[39;00m\n\u001b[0;32m 1315\u001b[0m \u001b[38;5;66;03m# algos.take_nd call above.\u001b[39;00m\n",
|
117 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\array_algos\\take.py:117\u001b[0m, in \u001b[0;36mtake_nd\u001b[1;34m(arr, indexer, axis, fill_value, allow_fill)\u001b[0m\n\u001b[0;32m 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m arr\u001b[38;5;241m.\u001b[39mtake(indexer, fill_value\u001b[38;5;241m=\u001b[39mfill_value, allow_fill\u001b[38;5;241m=\u001b[39mallow_fill)\n\u001b[0;32m 116\u001b[0m arr \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39masarray(arr)\n\u001b[1;32m--> 117\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_take_nd_ndarray\u001b[49m\u001b[43m(\u001b[49m\u001b[43marr\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindexer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfill_value\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mallow_fill\u001b[49m\u001b[43m)\u001b[49m\n",
|
118 |
-
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\pandas\\core\\array_algos\\take.py:157\u001b[0m, in \u001b[0;36m_take_nd_ndarray\u001b[1;34m(arr, indexer, axis, fill_value, allow_fill)\u001b[0m\n\u001b[0;32m 155\u001b[0m out \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mempty(out_shape, dtype\u001b[38;5;241m=\u001b[39mdtype, order\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mF\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 156\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 157\u001b[0m out \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mempty(out_shape, dtype\u001b[38;5;241m=\u001b[39mdtype)\n\u001b[0;32m 159\u001b[0m func \u001b[38;5;241m=\u001b[39m _get_take_nd_function(\n\u001b[0;32m 160\u001b[0m arr\u001b[38;5;241m.\u001b[39mndim, arr\u001b[38;5;241m.\u001b[39mdtype, out\u001b[38;5;241m.\u001b[39mdtype, axis\u001b[38;5;241m=\u001b[39maxis, mask_info\u001b[38;5;241m=\u001b[39mmask_info\n\u001b[0;32m 161\u001b[0m )\n\u001b[0;32m 162\u001b[0m func(arr, indexer, out, fill_value)\n",
|
119 |
-
"\u001b[1;31mMemoryError\u001b[0m: Unable to allocate 8.15 GiB for an array with shape (528, 2070713) and data type float64"
|
120 |
]
|
121 |
}
|
122 |
],
|
@@ -130,7 +96,7 @@
|
|
130 |
},
|
131 |
{
|
132 |
"cell_type": "code",
|
133 |
-
"execution_count":
|
134 |
"metadata": {},
|
135 |
"outputs": [
|
136 |
{
|
@@ -165,11 +131,11 @@
|
|
165 |
" <th>zone_066_fan_spd</th>\n",
|
166 |
" <th>zone_042_temp</th>\n",
|
167 |
" <th>...</th>\n",
|
168 |
-
" <th>
|
169 |
-
" <th>
|
170 |
-
" <th>
|
171 |
-
" <th>
|
172 |
-
" <th>
|
173 |
" <th>air_temp_set_1</th>\n",
|
174 |
" <th>air_temp_set_2</th>\n",
|
175 |
" <th>dew_point_temperature_set_1d</th>\n",
|
@@ -179,124 +145,124 @@
|
|
179 |
" </thead>\n",
|
180 |
" <tbody>\n",
|
181 |
" <tr>\n",
|
182 |
-
" <th>
|
183 |
-
" <td>
|
184 |
-
" <td>
|
185 |
-
" <td>20.0</td>\n",
|
186 |
-
" <td>73.2</td>\n",
|
187 |
-
" <td>70.0</td>\n",
|
188 |
-
" <td>71.2</td>\n",
|
189 |
-
" <td>20.0</td>\n",
|
190 |
-
" <td>70.4</td>\n",
|
191 |
-
" <td>35.0</td>\n",
|
192 |
-
" <td>71.6</td>\n",
|
193 |
-
" <td>...</td>\n",
|
194 |
-
" <td>NaN</td>\n",
|
195 |
-
" <td>NaN</td>\n",
|
196 |
" <td>NaN</td>\n",
|
|
|
|
|
|
|
197 |
" <td>NaN</td>\n",
|
|
|
198 |
" <td>NaN</td>\n",
|
199 |
-
" <td>
|
200 |
-
" <td
|
201 |
-
" <td>
|
202 |
-
" <td>
|
203 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
" </tr>\n",
|
205 |
" <tr>\n",
|
206 |
-
" <th>
|
207 |
-
" <td>
|
208 |
-
" <td>
|
209 |
-
" <td>20.0</td>\n",
|
210 |
-
" <td>73.2</td>\n",
|
211 |
-
" <td>70.0</td>\n",
|
212 |
-
" <td>71.2</td>\n",
|
213 |
-
" <td>20.0</td>\n",
|
214 |
-
" <td>70.4</td>\n",
|
215 |
-
" <td>35.0</td>\n",
|
216 |
-
" <td>71.6</td>\n",
|
217 |
-
" <td>...</td>\n",
|
218 |
-
" <td>NaN</td>\n",
|
219 |
-
" <td>NaN</td>\n",
|
220 |
" <td>NaN</td>\n",
|
|
|
|
|
|
|
221 |
" <td>NaN</td>\n",
|
|
|
222 |
" <td>NaN</td>\n",
|
223 |
-
" <td>
|
224 |
-
" <td
|
225 |
-
" <td>
|
226 |
-
" <td>
|
227 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
" </tr>\n",
|
229 |
" <tr>\n",
|
230 |
-
" <th>
|
231 |
-
" <td>
|
232 |
-
" <td>
|
233 |
-
" <td>20.0</td>\n",
|
234 |
-
" <td>73.2</td>\n",
|
235 |
-
" <td>70.0</td>\n",
|
236 |
-
" <td>71.2</td>\n",
|
237 |
-
" <td>20.0</td>\n",
|
238 |
-
" <td>70.4</td>\n",
|
239 |
-
" <td>35.0</td>\n",
|
240 |
-
" <td>71.6</td>\n",
|
241 |
-
" <td>...</td>\n",
|
242 |
-
" <td>NaN</td>\n",
|
243 |
-
" <td>NaN</td>\n",
|
244 |
" <td>NaN</td>\n",
|
|
|
|
|
|
|
245 |
" <td>NaN</td>\n",
|
|
|
246 |
" <td>NaN</td>\n",
|
247 |
-
" <td>
|
248 |
-
" <td
|
249 |
-
" <td>
|
250 |
-
" <td>
|
251 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
" </tr>\n",
|
253 |
" <tr>\n",
|
254 |
-
" <th>
|
255 |
-
" <td>
|
256 |
-
" <td>
|
257 |
-
" <td>20.0</td>\n",
|
258 |
-
" <td>73.2</td>\n",
|
259 |
-
" <td>70.0</td>\n",
|
260 |
-
" <td>71.2</td>\n",
|
261 |
-
" <td>20.0</td>\n",
|
262 |
-
" <td>70.4</td>\n",
|
263 |
-
" <td>35.0</td>\n",
|
264 |
-
" <td>71.6</td>\n",
|
265 |
-
" <td>...</td>\n",
|
266 |
-
" <td>NaN</td>\n",
|
267 |
-
" <td>NaN</td>\n",
|
268 |
" <td>NaN</td>\n",
|
|
|
|
|
|
|
269 |
" <td>NaN</td>\n",
|
|
|
270 |
" <td>NaN</td>\n",
|
271 |
-
" <td>
|
272 |
-
" <td
|
273 |
-
" <td>
|
274 |
-
" <td>
|
275 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
" </tr>\n",
|
277 |
" <tr>\n",
|
278 |
-
" <th>
|
279 |
-
" <td>
|
280 |
-
" <td>
|
281 |
-
" <td>20.0</td>\n",
|
282 |
-
" <td>73.2</td>\n",
|
283 |
-
" <td>70.0</td>\n",
|
284 |
-
" <td>71.2</td>\n",
|
285 |
-
" <td>20.0</td>\n",
|
286 |
-
" <td>70.4</td>\n",
|
287 |
-
" <td>35.0</td>\n",
|
288 |
-
" <td>71.6</td>\n",
|
289 |
-
" <td>...</td>\n",
|
290 |
-
" <td>NaN</td>\n",
|
291 |
-
" <td>NaN</td>\n",
|
292 |
" <td>NaN</td>\n",
|
|
|
|
|
|
|
293 |
" <td>NaN</td>\n",
|
|
|
294 |
" <td>NaN</td>\n",
|
295 |
-
" <td>
|
296 |
-
" <td
|
297 |
-
" <td>
|
298 |
-
" <td>
|
299 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
" </tr>\n",
|
301 |
" <tr>\n",
|
302 |
" <th>...</th>\n",
|
@@ -335,11 +301,11 @@
|
|
335 |
" <td>35.0</td>\n",
|
336 |
" <td>71.4</td>\n",
|
337 |
" <td>...</td>\n",
|
|
|
|
|
338 |
" <td>68.0</td>\n",
|
|
|
339 |
" <td>68.0</td>\n",
|
340 |
-
" <td>68.0</td>\n",
|
341 |
-
" <td>65.0</td>\n",
|
342 |
-
" <td>67.0</td>\n",
|
343 |
" <td>13.994</td>\n",
|
344 |
" <td>13.528</td>\n",
|
345 |
" <td>4.11</td>\n",
|
@@ -359,11 +325,11 @@
|
|
359 |
" <td>35.0</td>\n",
|
360 |
" <td>71.4</td>\n",
|
361 |
" <td>...</td>\n",
|
|
|
|
|
362 |
" <td>68.0</td>\n",
|
|
|
363 |
" <td>68.0</td>\n",
|
364 |
-
" <td>68.0</td>\n",
|
365 |
-
" <td>65.0</td>\n",
|
366 |
-
" <td>67.0</td>\n",
|
367 |
" <td>13.994</td>\n",
|
368 |
" <td>13.528</td>\n",
|
369 |
" <td>4.11</td>\n",
|
@@ -383,11 +349,11 @@
|
|
383 |
" <td>35.0</td>\n",
|
384 |
" <td>71.4</td>\n",
|
385 |
" <td>...</td>\n",
|
|
|
|
|
386 |
" <td>68.0</td>\n",
|
|
|
387 |
" <td>68.0</td>\n",
|
388 |
-
" <td>68.0</td>\n",
|
389 |
-
" <td>65.0</td>\n",
|
390 |
-
" <td>67.0</td>\n",
|
391 |
" <td>13.994</td>\n",
|
392 |
" <td>13.528</td>\n",
|
393 |
" <td>4.11</td>\n",
|
@@ -407,11 +373,11 @@
|
|
407 |
" <td>35.0</td>\n",
|
408 |
" <td>71.4</td>\n",
|
409 |
" <td>...</td>\n",
|
|
|
|
|
410 |
" <td>68.0</td>\n",
|
|
|
411 |
" <td>68.0</td>\n",
|
412 |
-
" <td>68.0</td>\n",
|
413 |
-
" <td>65.0</td>\n",
|
414 |
-
" <td>67.0</td>\n",
|
415 |
" <td>13.994</td>\n",
|
416 |
" <td>13.528</td>\n",
|
417 |
" <td>4.11</td>\n",
|
@@ -431,11 +397,11 @@
|
|
431 |
" <td>35.0</td>\n",
|
432 |
" <td>71.4</td>\n",
|
433 |
" <td>...</td>\n",
|
|
|
|
|
434 |
" <td>68.0</td>\n",
|
|
|
435 |
" <td>68.0</td>\n",
|
436 |
-
" <td>68.0</td>\n",
|
437 |
-
" <td>65.0</td>\n",
|
438 |
-
" <td>67.0</td>\n",
|
439 |
" <td>13.994</td>\n",
|
440 |
" <td>13.528</td>\n",
|
441 |
" <td>4.11</td>\n",
|
@@ -444,16 +410,16 @@
|
|
444 |
" </tr>\n",
|
445 |
" </tbody>\n",
|
446 |
"</table>\n",
|
447 |
-
"<p>
|
448 |
"</div>"
|
449 |
],
|
450 |
"text/plain": [
|
451 |
" date zone_069_temp zone_069_fan_spd zone_068_temp \\\n",
|
452 |
-
"
|
453 |
-
"
|
454 |
-
"
|
455 |
-
"
|
456 |
-
"
|
457 |
"... ... ... ... ... \n",
|
458 |
"2072148 2020-12-31 23:57:00 68.8 20.0 71.7 \n",
|
459 |
"2072149 2020-12-31 23:58:00 68.8 20.0 71.7 \n",
|
@@ -462,11 +428,11 @@
|
|
462 |
"2072152 2020-12-31 23:59:00 68.8 20.0 71.7 \n",
|
463 |
"\n",
|
464 |
" zone_068_fan_spd zone_067_temp zone_067_fan_spd zone_066_temp \\\n",
|
465 |
-
"
|
466 |
-
"
|
467 |
-
"
|
468 |
-
"
|
469 |
-
"
|
470 |
"... ... ... ... ... \n",
|
471 |
"2072148 20.0 70.4 20.0 68.6 \n",
|
472 |
"2072149 20.0 70.4 20.0 68.6 \n",
|
@@ -474,51 +440,51 @@
|
|
474 |
"2072151 20.0 70.4 20.0 68.6 \n",
|
475 |
"2072152 20.0 70.4 20.0 68.6 \n",
|
476 |
"\n",
|
477 |
-
" zone_066_fan_spd zone_042_temp ...
|
478 |
-
"
|
479 |
-
"
|
480 |
-
"
|
481 |
-
"
|
482 |
-
"
|
483 |
"... ... ... ... ... \n",
|
484 |
-
"2072148 35.0 71.4 ...
|
485 |
-
"2072149 35.0 71.4 ...
|
486 |
-
"2072150 35.0 71.4 ...
|
487 |
-
"2072151 35.0 71.4 ...
|
488 |
-
"2072152 35.0 71.4 ...
|
489 |
"\n",
|
490 |
-
"
|
491 |
-
"
|
492 |
-
"
|
493 |
-
"
|
494 |
-
"
|
495 |
-
"
|
496 |
"... ... ... ... \n",
|
497 |
-
"2072148
|
498 |
-
"2072149
|
499 |
-
"2072150
|
500 |
-
"2072151
|
501 |
-
"2072152
|
502 |
"\n",
|
503 |
-
"
|
504 |
-
"
|
505 |
-
"
|
506 |
-
"
|
507 |
-
"
|
508 |
-
"
|
509 |
"... ... ... ... \n",
|
510 |
-
"2072148
|
511 |
-
"2072149
|
512 |
-
"2072150
|
513 |
-
"2072151
|
514 |
-
"2072152
|
515 |
"\n",
|
516 |
" dew_point_temperature_set_1d relative_humidity_set_1 \\\n",
|
517 |
-
"
|
518 |
-
"
|
519 |
-
"
|
520 |
-
"
|
521 |
-
"
|
522 |
"... ... ... \n",
|
523 |
"2072148 4.11 51.61 \n",
|
524 |
"2072149 4.11 51.61 \n",
|
@@ -527,11 +493,11 @@
|
|
527 |
"2072152 4.11 51.61 \n",
|
528 |
"\n",
|
529 |
" solar_radiation_set_1 \n",
|
530 |
-
"
|
531 |
-
"
|
532 |
-
"
|
533 |
-
"
|
534 |
-
"
|
535 |
"... ... \n",
|
536 |
"2072148 188.8 \n",
|
537 |
"2072149 188.8 \n",
|
@@ -539,10 +505,10 @@
|
|
539 |
"2072151 188.8 \n",
|
540 |
"2072152 188.8 \n",
|
541 |
"\n",
|
542 |
-
"[
|
543 |
]
|
544 |
},
|
545 |
-
"execution_count":
|
546 |
"metadata": {},
|
547 |
"output_type": "execute_result"
|
548 |
}
|
@@ -553,39 +519,28 @@
|
|
553 |
},
|
554 |
{
|
555 |
"cell_type": "code",
|
556 |
-
"execution_count":
|
557 |
"metadata": {},
|
558 |
"outputs": [
|
559 |
{
|
560 |
"data": {
|
561 |
"text/plain": [
|
562 |
-
"[
|
563 |
-
" 'zone_070_heating_sp',\n",
|
564 |
-
" 'zone_070_heating_sp',\n",
|
565 |
-
" 'zone_070_heating_sp',\n",
|
566 |
-
" 'zone_070_heating_sp',\n",
|
567 |
-
" 'zone_070_heating_sp',\n",
|
568 |
-
" 'zone_070_heating_sp',\n",
|
569 |
-
" 'zone_070_heating_sp',\n",
|
570 |
-
" 'zone_070_heating_sp',\n",
|
571 |
-
" 'zone_070_heating_sp',\n",
|
572 |
-
" 'zone_070_heating_sp',\n",
|
573 |
-
" 'zone_070_heating_sp']"
|
574 |
]
|
575 |
},
|
576 |
-
"execution_count":
|
577 |
"metadata": {},
|
578 |
"output_type": "execute_result"
|
579 |
}
|
580 |
],
|
581 |
"source": [
|
582 |
-
"testdataset_df = df_filtered[(df_filtered.date.dt.date >date(
|
583 |
"\n",
|
584 |
"# traindataset_df = df_filtered[ (df_filtered.date.dt.date >date(2019, 11, 8))]\n",
|
585 |
"\n",
|
586 |
-
"traindataset_df = df_filtered[(df_filtered.date.dt.date >date(2019, 3, 1)) & (df_filtered.date.dt.date <date(
|
587 |
-
"testdataset = testdataset_df.drop(columns=[\"date\"]).
|
588 |
-
"traindataset = traindataset_df.drop(columns=[\"date\"]).
|
589 |
"\n",
|
590 |
"columns_with_na = traindataset_df.columns[traindataset_df.isna().any()].tolist()\n",
|
591 |
"columns_with_na"
|
@@ -593,35 +548,7 @@
|
|
593 |
},
|
594 |
{
|
595 |
"cell_type": "code",
|
596 |
-
"execution_count":
|
597 |
-
"metadata": {},
|
598 |
-
"outputs": [
|
599 |
-
{
|
600 |
-
"data": {
|
601 |
-
"text/plain": [
|
602 |
-
"Index(['date', 'zone_069_temp', 'zone_069_fan_spd', 'zone_068_temp',\n",
|
603 |
-
" 'zone_068_fan_spd', 'zone_067_temp', 'zone_067_fan_spd',\n",
|
604 |
-
" 'zone_066_temp', 'zone_066_fan_spd', 'zone_042_temp',\n",
|
605 |
-
" ...\n",
|
606 |
-
" 'zone_066_heating_sp', 'zone_067_heating_sp', 'zone_069_heating_sp',\n",
|
607 |
-
" 'zone_070_heating_sp', 'zone_071_heating_sp', 'air_temp_set_1',\n",
|
608 |
-
" 'air_temp_set_2', 'dew_point_temperature_set_1d',\n",
|
609 |
-
" 'relative_humidity_set_1', 'solar_radiation_set_1'],\n",
|
610 |
-
" dtype='object', length=529)"
|
611 |
-
]
|
612 |
-
},
|
613 |
-
"execution_count": 9,
|
614 |
-
"metadata": {},
|
615 |
-
"output_type": "execute_result"
|
616 |
-
}
|
617 |
-
],
|
618 |
-
"source": [
|
619 |
-
"traindataset_df.columns"
|
620 |
-
]
|
621 |
-
},
|
622 |
-
{
|
623 |
-
"cell_type": "code",
|
624 |
-
"execution_count": 123,
|
625 |
"metadata": {},
|
626 |
"outputs": [
|
627 |
{
|
@@ -638,16 +565,16 @@
|
|
638 |
},
|
639 |
{
|
640 |
"cell_type": "code",
|
641 |
-
"execution_count":
|
642 |
"metadata": {},
|
643 |
"outputs": [
|
644 |
{
|
645 |
"data": {
|
646 |
"text/plain": [
|
647 |
-
"(
|
648 |
]
|
649 |
},
|
650 |
-
"execution_count":
|
651 |
"metadata": {},
|
652 |
"output_type": "execute_result"
|
653 |
}
|
@@ -658,7 +585,7 @@
|
|
658 |
},
|
659 |
{
|
660 |
"cell_type": "code",
|
661 |
-
"execution_count":
|
662 |
"metadata": {},
|
663 |
"outputs": [],
|
664 |
"source": [
|
@@ -672,16 +599,16 @@
|
|
672 |
},
|
673 |
{
|
674 |
"cell_type": "code",
|
675 |
-
"execution_count":
|
676 |
"metadata": {},
|
677 |
"outputs": [
|
678 |
{
|
679 |
"data": {
|
680 |
"text/plain": [
|
681 |
-
"(
|
682 |
]
|
683 |
},
|
684 |
-
"execution_count":
|
685 |
"metadata": {},
|
686 |
"output_type": "execute_result"
|
687 |
}
|
@@ -692,7 +619,7 @@
|
|
692 |
},
|
693 |
{
|
694 |
"cell_type": "code",
|
695 |
-
"execution_count":
|
696 |
"metadata": {},
|
697 |
"outputs": [],
|
698 |
"source": [
|
@@ -703,7 +630,7 @@
|
|
703 |
" Y = []\n",
|
704 |
" for i in range(len(dataset) - time_step - 1):\n",
|
705 |
" x.append(dataset[i:(i+time_step),:])\n",
|
706 |
-
" Y.append(dataset[i+time_step,0
|
707 |
" x= np.array(x)\n",
|
708 |
" Y = np.array(Y)\n",
|
709 |
" return x,Y\n",
|
@@ -715,16 +642,16 @@
|
|
715 |
},
|
716 |
{
|
717 |
"cell_type": "code",
|
718 |
-
"execution_count":
|
719 |
"metadata": {},
|
720 |
"outputs": [
|
721 |
{
|
722 |
"data": {
|
723 |
"text/plain": [
|
724 |
-
"((
|
725 |
]
|
726 |
},
|
727 |
-
"execution_count":
|
728 |
"metadata": {},
|
729 |
"output_type": "execute_result"
|
730 |
}
|
@@ -735,7 +662,7 @@
|
|
735 |
},
|
736 |
{
|
737 |
"cell_type": "code",
|
738 |
-
"execution_count":
|
739 |
"metadata": {},
|
740 |
"outputs": [
|
741 |
{
|
@@ -743,8 +670,8 @@
|
|
743 |
"output_type": "stream",
|
744 |
"text": [
|
745 |
"Epoch 1/5\n",
|
746 |
-
"
|
747 |
-
"Epoch 1: val_loss improved from inf to 0.
|
748 |
"INFO:tensorflow:Assets written to: lstm_vav_01.tf\\assets\n"
|
749 |
]
|
750 |
},
|
@@ -759,10 +686,10 @@
|
|
759 |
"name": "stdout",
|
760 |
"output_type": "stream",
|
761 |
"text": [
|
762 |
-
"
|
763 |
"Epoch 2/5\n",
|
764 |
-
"
|
765 |
-
"Epoch 2: val_loss improved from 0.
|
766 |
"INFO:tensorflow:Assets written to: lstm_vav_01.tf\\assets\n"
|
767 |
]
|
768 |
},
|
@@ -777,72 +704,31 @@
|
|
777 |
"name": "stdout",
|
778 |
"output_type": "stream",
|
779 |
"text": [
|
780 |
-
"
|
781 |
"Epoch 3/5\n",
|
782 |
-
"
|
783 |
-
"Epoch 3: val_loss improved from 0.21391 to 0.17155, saving model to lstm_vav_01.tf\n",
|
784 |
-
"INFO:tensorflow:Assets written to: lstm_vav_01.tf\\assets\n"
|
785 |
-
]
|
786 |
-
},
|
787 |
-
{
|
788 |
-
"name": "stderr",
|
789 |
-
"output_type": "stream",
|
790 |
-
"text": [
|
791 |
-
"INFO:tensorflow:Assets written to: lstm_vav_01.tf\\assets\n"
|
792 |
-
]
|
793 |
-
},
|
794 |
-
{
|
795 |
-
"name": "stdout",
|
796 |
-
"output_type": "stream",
|
797 |
-
"text": [
|
798 |
-
"675/675 [==============================] - 58s 86ms/step - loss: 0.0081 - val_loss: 0.1716\n",
|
799 |
-
"Epoch 4/5\n",
|
800 |
-
"675/675 [==============================] - ETA: 0s - loss: 0.0049\n",
|
801 |
-
"Epoch 4: val_loss improved from 0.17155 to 0.14438, saving model to lstm_vav_01.tf\n",
|
802 |
-
"INFO:tensorflow:Assets written to: lstm_vav_01.tf\\assets\n"
|
803 |
]
|
804 |
},
|
805 |
{
|
806 |
-
"
|
807 |
-
"
|
808 |
-
"
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
"
|
815 |
-
|
816 |
-
"
|
817 |
-
"
|
818 |
-
"
|
819 |
-
"
|
820 |
-
"
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
"name": "stderr",
|
825 |
-
"output_type": "stream",
|
826 |
-
"text": [
|
827 |
-
"INFO:tensorflow:Assets written to: lstm_vav_01.tf\\assets\n"
|
828 |
-
]
|
829 |
-
},
|
830 |
-
{
|
831 |
-
"name": "stdout",
|
832 |
-
"output_type": "stream",
|
833 |
-
"text": [
|
834 |
-
"675/675 [==============================] - 60s 89ms/step - loss: 0.0030 - val_loss: 0.1241\n"
|
835 |
]
|
836 |
-
},
|
837 |
-
{
|
838 |
-
"data": {
|
839 |
-
"text/plain": [
|
840 |
-
"<keras.src.callbacks.History at 0x1d5bf064950>"
|
841 |
-
]
|
842 |
-
},
|
843 |
-
"execution_count": 133,
|
844 |
-
"metadata": {},
|
845 |
-
"output_type": "execute_result"
|
846 |
}
|
847 |
],
|
848 |
"source": [
|
@@ -862,16 +748,16 @@
|
|
862 |
},
|
863 |
{
|
864 |
"cell_type": "code",
|
865 |
-
"execution_count":
|
866 |
"metadata": {},
|
867 |
"outputs": [
|
868 |
{
|
869 |
"data": {
|
870 |
"text/plain": [
|
871 |
-
"<tensorflow.python.checkpoint.checkpoint.CheckpointLoadStatus at
|
872 |
]
|
873 |
},
|
874 |
-
"execution_count":
|
875 |
"metadata": {},
|
876 |
"output_type": "execute_result"
|
877 |
}
|
@@ -882,14 +768,14 @@
|
|
882 |
},
|
883 |
{
|
884 |
"cell_type": "code",
|
885 |
-
"execution_count":
|
886 |
"metadata": {},
|
887 |
"outputs": [
|
888 |
{
|
889 |
"name": "stdout",
|
890 |
"output_type": "stream",
|
891 |
"text": [
|
892 |
-
"
|
893 |
]
|
894 |
}
|
895 |
],
|
@@ -899,32 +785,48 @@
|
|
899 |
},
|
900 |
{
|
901 |
"cell_type": "code",
|
902 |
-
"execution_count":
|
903 |
"metadata": {},
|
904 |
"outputs": [
|
905 |
{
|
906 |
"data": {
|
907 |
"text/plain": [
|
908 |
-
"[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
909 |
]
|
910 |
},
|
911 |
-
"execution_count":
|
912 |
"metadata": {},
|
913 |
"output_type": "execute_result"
|
914 |
}
|
915 |
],
|
916 |
"source": [
|
917 |
-
"
|
918 |
-
"plt.plot(y_train[:,3])"
|
919 |
]
|
920 |
},
|
921 |
{
|
922 |
"cell_type": "code",
|
923 |
-
"execution_count":
|
924 |
"metadata": {},
|
925 |
"outputs": [],
|
926 |
"source": [
|
927 |
"%matplotlib qt\n",
|
|
|
928 |
"var = 1\n",
|
929 |
"plt.plot(y_test[:,var], label='Original Testing Data', color='blue')\n",
|
930 |
"plt.plot(test_predict1[:,var], label='Predicted Testing Data', color='red',alpha=0.8)\n",
|
@@ -950,6 +852,7 @@
|
|
950 |
"import matplotlib.pyplot as plt\n",
|
951 |
"from sklearn.decomposition import PCA\n",
|
952 |
"\n",
|
|
|
953 |
"# Generating random data for demonstration\n",
|
954 |
"np.random.seed(0)\n",
|
955 |
"X = test_predict1 - y_test\n",
|
@@ -978,25 +881,15 @@
|
|
978 |
},
|
979 |
{
|
980 |
"cell_type": "code",
|
981 |
-
"execution_count":
|
982 |
"metadata": {},
|
983 |
-
"outputs": [
|
984 |
-
{
|
985 |
-
"ename": "ValueError",
|
986 |
-
"evalue": "operands could not be broadcast together with shapes (199403,51) (8,) ",
|
987 |
-
"output_type": "error",
|
988 |
-
"traceback": [
|
989 |
-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
990 |
-
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
|
991 |
-
"Cell \u001b[1;32mIn[19], line 6\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;66;03m# Generating random data for demonstration\u001b[39;00m\n\u001b[0;32m 5\u001b[0m np\u001b[38;5;241m.\u001b[39mrandom\u001b[38;5;241m.\u001b[39mseed(\u001b[38;5;241m0\u001b[39m)\n\u001b[1;32m----> 6\u001b[0m X \u001b[38;5;241m=\u001b[39m \u001b[43m(\u001b[49m\u001b[43mtest_predict1\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[43m \u001b[49m\u001b[43my_test\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mscaler\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvar_\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m:\u001b[49m\u001b[38;5;241;43m8\u001b[39;49m\u001b[43m]\u001b[49m \u001b[38;5;241m+\u001b[39m scaler\u001b[38;5;241m.\u001b[39mmean_[\u001b[38;5;241m0\u001b[39m:\u001b[38;5;241m8\u001b[39m]\n\u001b[0;32m 8\u001b[0m k \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m6\u001b[39m\n\u001b[0;32m 10\u001b[0m kmeans \u001b[38;5;241m=\u001b[39m KMeans(n_clusters\u001b[38;5;241m=\u001b[39mk)\n",
|
992 |
-
"\u001b[1;31mValueError\u001b[0m: operands could not be broadcast together with shapes (199403,51) (8,) "
|
993 |
-
]
|
994 |
-
}
|
995 |
-
],
|
996 |
"source": [
|
997 |
"from sklearn.cluster import KMeans\n",
|
998 |
"import numpy as np\n",
|
999 |
"import matplotlib.pyplot as plt\n",
|
|
|
|
|
1000 |
"# Generating random data for demonstration\n",
|
1001 |
"np.random.seed(0)\n",
|
1002 |
"X = (test_predict1 - y_test)\n",
|
@@ -1029,7 +922,7 @@
|
|
1029 |
},
|
1030 |
{
|
1031 |
"cell_type": "code",
|
1032 |
-
"execution_count":
|
1033 |
"metadata": {},
|
1034 |
"outputs": [],
|
1035 |
"source": [
|
@@ -1080,7 +973,7 @@
|
|
1080 |
},
|
1081 |
{
|
1082 |
"cell_type": "code",
|
1083 |
-
"execution_count":
|
1084 |
"metadata": {},
|
1085 |
"outputs": [],
|
1086 |
"source": [
|
@@ -1094,7 +987,7 @@
|
|
1094 |
"X = processed_data\n",
|
1095 |
"\n",
|
1096 |
"# Creating the GMM instance with desired number of clusters\n",
|
1097 |
-
"gmm = GaussianMixture(n_components=
|
1098 |
"\n",
|
1099 |
"# Fitting the model to the data\n",
|
1100 |
"gmm.fit(X)\n",
|
@@ -1118,7 +1011,7 @@
|
|
1118 |
},
|
1119 |
{
|
1120 |
"cell_type": "code",
|
1121 |
-
"execution_count":
|
1122 |
"metadata": {},
|
1123 |
"outputs": [],
|
1124 |
"source": [
|
@@ -1127,10 +1020,9 @@
|
|
1127 |
"import matplotlib.pyplot as plt\n",
|
1128 |
"# Generating random data for demonstration\n",
|
1129 |
"np.random.seed(0)\n",
|
1130 |
-
"X =
|
1131 |
-
"k = 6\n",
|
1132 |
"\n",
|
1133 |
-
"kmeans = KMeans(n_clusters=
|
1134 |
"\n",
|
1135 |
"kmeans.fit(X)\n",
|
1136 |
"\n",
|
@@ -1146,8 +1038,11 @@
|
|
1146 |
"labels = kmeans.labels_\n",
|
1147 |
"\n",
|
1148 |
"# Plotting the data points and cluster centers\n",
|
|
|
1149 |
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
1150 |
"plt.scatter(centroids[:, 0], centroids[:, 1], marker='x', c='red', s=200, linewidths=2)\n",
|
|
|
|
|
1151 |
"plt.title('KMeans Clustering')\n",
|
1152 |
"plt.xlabel('Feature 1')\n",
|
1153 |
"plt.ylabel('Feature 2')\n",
|
@@ -1156,10 +1051,23 @@
|
|
1156 |
},
|
1157 |
{
|
1158 |
"cell_type": "code",
|
1159 |
-
"execution_count":
|
1160 |
"metadata": {},
|
1161 |
-
"outputs": [
|
1162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1163 |
}
|
1164 |
],
|
1165 |
"metadata": {
|
|
|
31 |
},
|
32 |
{
|
33 |
"cell_type": "code",
|
34 |
+
"execution_count": 3,
|
35 |
"metadata": {},
|
36 |
+
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
"source": [
|
38 |
+
"zones = [69, 68,67, 66,65, 64, 42,41,40,39,38,37,36]\n",
|
39 |
"rtus = [1]\n",
|
40 |
"cols = []\n",
|
41 |
"\n",
|
|
|
46 |
"\n",
|
47 |
"for zone in zones:\n",
|
48 |
" for column in merged.columns:\n",
|
49 |
+
" if f\"zone_0{zone}\" in column: \n",
|
50 |
+
" if \"cooling_sp\" in column or \"heating_sp\" in column:\n",
|
51 |
+
" cols.append(column)\n",
|
52 |
"# for rtu in rtus:\n",
|
53 |
"# for column in merged.columns:\n",
|
54 |
"# if f\"rtu_00{rtu}_fltrd_sa\" in column:\n",
|
|
|
63 |
},
|
64 |
{
|
65 |
"cell_type": "code",
|
66 |
+
"execution_count": 4,
|
67 |
"metadata": {},
|
68 |
"outputs": [
|
69 |
{
|
70 |
"name": "stderr",
|
71 |
"output_type": "stream",
|
72 |
"text": [
|
73 |
+
"C:\\Users\\arbal\\AppData\\Local\\Temp\\ipykernel_16740\\4293840618.py:1: SettingWithCopyWarning: \n",
|
74 |
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
75 |
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
76 |
"\n",
|
|
|
79 |
]
|
80 |
},
|
81 |
{
|
82 |
+
"name": "stdout",
|
83 |
+
"output_type": "stream",
|
84 |
+
"text": [
|
85 |
+
"There are NA values in the DataFrame columns.\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
]
|
87 |
}
|
88 |
],
|
|
|
96 |
},
|
97 |
{
|
98 |
"cell_type": "code",
|
99 |
+
"execution_count": 5,
|
100 |
"metadata": {},
|
101 |
"outputs": [
|
102 |
{
|
|
|
131 |
" <th>zone_066_fan_spd</th>\n",
|
132 |
" <th>zone_042_temp</th>\n",
|
133 |
" <th>...</th>\n",
|
134 |
+
" <th>zone_038_heating_sp</th>\n",
|
135 |
+
" <th>zone_037_cooling_sp</th>\n",
|
136 |
+
" <th>zone_037_heating_sp</th>\n",
|
137 |
+
" <th>zone_036_cooling_sp</th>\n",
|
138 |
+
" <th>zone_036_heating_sp</th>\n",
|
139 |
" <th>air_temp_set_1</th>\n",
|
140 |
" <th>air_temp_set_2</th>\n",
|
141 |
" <th>dew_point_temperature_set_1d</th>\n",
|
|
|
145 |
" </thead>\n",
|
146 |
" <tbody>\n",
|
147 |
" <tr>\n",
|
148 |
+
" <th>438785</th>\n",
|
149 |
+
" <td>2019-01-08 20:55:00</td>\n",
|
150 |
+
" <td>70.9</td>\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
" <td>NaN</td>\n",
|
152 |
+
" <td>72.4</td>\n",
|
153 |
+
" <td>20.0</td>\n",
|
154 |
+
" <td>70.2</td>\n",
|
155 |
" <td>NaN</td>\n",
|
156 |
+
" <td>70.9</td>\n",
|
157 |
" <td>NaN</td>\n",
|
158 |
+
" <td>72.3</td>\n",
|
159 |
+
" <td>...</td>\n",
|
160 |
+
" <td>72.0</td>\n",
|
161 |
+
" <td>73.0</td>\n",
|
162 |
+
" <td>70.0</td>\n",
|
163 |
+
" <td>75.0</td>\n",
|
164 |
+
" <td>72.0</td>\n",
|
165 |
+
" <td>12.850</td>\n",
|
166 |
+
" <td>12.930</td>\n",
|
167 |
+
" <td>9.10</td>\n",
|
168 |
+
" <td>78.15</td>\n",
|
169 |
+
" <td>48.7</td>\n",
|
170 |
" </tr>\n",
|
171 |
" <tr>\n",
|
172 |
+
" <th>438786</th>\n",
|
173 |
+
" <td>2019-01-08 20:56:00</td>\n",
|
174 |
+
" <td>70.9</td>\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
" <td>NaN</td>\n",
|
176 |
+
" <td>72.4</td>\n",
|
177 |
+
" <td>20.0</td>\n",
|
178 |
+
" <td>70.2</td>\n",
|
179 |
" <td>NaN</td>\n",
|
180 |
+
" <td>70.9</td>\n",
|
181 |
" <td>NaN</td>\n",
|
182 |
+
" <td>72.3</td>\n",
|
183 |
+
" <td>...</td>\n",
|
184 |
+
" <td>72.0</td>\n",
|
185 |
+
" <td>73.0</td>\n",
|
186 |
+
" <td>70.0</td>\n",
|
187 |
+
" <td>75.0</td>\n",
|
188 |
+
" <td>72.0</td>\n",
|
189 |
+
" <td>12.850</td>\n",
|
190 |
+
" <td>12.930</td>\n",
|
191 |
+
" <td>9.10</td>\n",
|
192 |
+
" <td>78.15</td>\n",
|
193 |
+
" <td>48.7</td>\n",
|
194 |
" </tr>\n",
|
195 |
" <tr>\n",
|
196 |
+
" <th>438787</th>\n",
|
197 |
+
" <td>2019-01-08 20:57:00</td>\n",
|
198 |
+
" <td>70.9</td>\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
" <td>NaN</td>\n",
|
200 |
+
" <td>72.4</td>\n",
|
201 |
+
" <td>20.0</td>\n",
|
202 |
+
" <td>70.2</td>\n",
|
203 |
" <td>NaN</td>\n",
|
204 |
+
" <td>70.9</td>\n",
|
205 |
" <td>NaN</td>\n",
|
206 |
+
" <td>72.3</td>\n",
|
207 |
+
" <td>...</td>\n",
|
208 |
+
" <td>72.0</td>\n",
|
209 |
+
" <td>73.0</td>\n",
|
210 |
+
" <td>70.0</td>\n",
|
211 |
+
" <td>75.0</td>\n",
|
212 |
+
" <td>72.0</td>\n",
|
213 |
+
" <td>12.850</td>\n",
|
214 |
+
" <td>12.930</td>\n",
|
215 |
+
" <td>9.10</td>\n",
|
216 |
+
" <td>78.15</td>\n",
|
217 |
+
" <td>48.7</td>\n",
|
218 |
" </tr>\n",
|
219 |
" <tr>\n",
|
220 |
+
" <th>438788</th>\n",
|
221 |
+
" <td>2019-01-08 20:58:00</td>\n",
|
222 |
+
" <td>70.9</td>\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
" <td>NaN</td>\n",
|
224 |
+
" <td>72.4</td>\n",
|
225 |
+
" <td>20.0</td>\n",
|
226 |
+
" <td>70.2</td>\n",
|
227 |
" <td>NaN</td>\n",
|
228 |
+
" <td>70.9</td>\n",
|
229 |
" <td>NaN</td>\n",
|
230 |
+
" <td>72.3</td>\n",
|
231 |
+
" <td>...</td>\n",
|
232 |
+
" <td>72.0</td>\n",
|
233 |
+
" <td>73.0</td>\n",
|
234 |
+
" <td>70.0</td>\n",
|
235 |
+
" <td>75.0</td>\n",
|
236 |
+
" <td>72.0</td>\n",
|
237 |
+
" <td>12.850</td>\n",
|
238 |
+
" <td>12.930</td>\n",
|
239 |
+
" <td>9.10</td>\n",
|
240 |
+
" <td>78.15</td>\n",
|
241 |
+
" <td>48.7</td>\n",
|
242 |
" </tr>\n",
|
243 |
" <tr>\n",
|
244 |
+
" <th>438789</th>\n",
|
245 |
+
" <td>2019-01-08 20:59:00</td>\n",
|
246 |
+
" <td>70.9</td>\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
" <td>NaN</td>\n",
|
248 |
+
" <td>72.4</td>\n",
|
249 |
+
" <td>20.0</td>\n",
|
250 |
+
" <td>70.2</td>\n",
|
251 |
" <td>NaN</td>\n",
|
252 |
+
" <td>70.9</td>\n",
|
253 |
" <td>NaN</td>\n",
|
254 |
+
" <td>72.3</td>\n",
|
255 |
+
" <td>...</td>\n",
|
256 |
+
" <td>72.0</td>\n",
|
257 |
+
" <td>73.0</td>\n",
|
258 |
+
" <td>70.0</td>\n",
|
259 |
+
" <td>75.0</td>\n",
|
260 |
+
" <td>72.0</td>\n",
|
261 |
+
" <td>12.850</td>\n",
|
262 |
+
" <td>12.930</td>\n",
|
263 |
+
" <td>9.10</td>\n",
|
264 |
+
" <td>78.15</td>\n",
|
265 |
+
" <td>48.7</td>\n",
|
266 |
" </tr>\n",
|
267 |
" <tr>\n",
|
268 |
" <th>...</th>\n",
|
|
|
301 |
" <td>35.0</td>\n",
|
302 |
" <td>71.4</td>\n",
|
303 |
" <td>...</td>\n",
|
304 |
+
" <td>71.0</td>\n",
|
305 |
+
" <td>74.0</td>\n",
|
306 |
" <td>68.0</td>\n",
|
307 |
+
" <td>74.0</td>\n",
|
308 |
" <td>68.0</td>\n",
|
|
|
|
|
|
|
309 |
" <td>13.994</td>\n",
|
310 |
" <td>13.528</td>\n",
|
311 |
" <td>4.11</td>\n",
|
|
|
325 |
" <td>35.0</td>\n",
|
326 |
" <td>71.4</td>\n",
|
327 |
" <td>...</td>\n",
|
328 |
+
" <td>71.0</td>\n",
|
329 |
+
" <td>74.0</td>\n",
|
330 |
" <td>68.0</td>\n",
|
331 |
+
" <td>74.0</td>\n",
|
332 |
" <td>68.0</td>\n",
|
|
|
|
|
|
|
333 |
" <td>13.994</td>\n",
|
334 |
" <td>13.528</td>\n",
|
335 |
" <td>4.11</td>\n",
|
|
|
349 |
" <td>35.0</td>\n",
|
350 |
" <td>71.4</td>\n",
|
351 |
" <td>...</td>\n",
|
352 |
+
" <td>71.0</td>\n",
|
353 |
+
" <td>74.0</td>\n",
|
354 |
" <td>68.0</td>\n",
|
355 |
+
" <td>74.0</td>\n",
|
356 |
" <td>68.0</td>\n",
|
|
|
|
|
|
|
357 |
" <td>13.994</td>\n",
|
358 |
" <td>13.528</td>\n",
|
359 |
" <td>4.11</td>\n",
|
|
|
373 |
" <td>35.0</td>\n",
|
374 |
" <td>71.4</td>\n",
|
375 |
" <td>...</td>\n",
|
376 |
+
" <td>71.0</td>\n",
|
377 |
+
" <td>74.0</td>\n",
|
378 |
" <td>68.0</td>\n",
|
379 |
+
" <td>74.0</td>\n",
|
380 |
" <td>68.0</td>\n",
|
|
|
|
|
|
|
381 |
" <td>13.994</td>\n",
|
382 |
" <td>13.528</td>\n",
|
383 |
" <td>4.11</td>\n",
|
|
|
397 |
" <td>35.0</td>\n",
|
398 |
" <td>71.4</td>\n",
|
399 |
" <td>...</td>\n",
|
400 |
+
" <td>71.0</td>\n",
|
401 |
+
" <td>74.0</td>\n",
|
402 |
" <td>68.0</td>\n",
|
403 |
+
" <td>74.0</td>\n",
|
404 |
" <td>68.0</td>\n",
|
|
|
|
|
|
|
405 |
" <td>13.994</td>\n",
|
406 |
" <td>13.528</td>\n",
|
407 |
" <td>4.11</td>\n",
|
|
|
410 |
" </tr>\n",
|
411 |
" </tbody>\n",
|
412 |
"</table>\n",
|
413 |
+
"<p>1633368 rows × 46 columns</p>\n",
|
414 |
"</div>"
|
415 |
],
|
416 |
"text/plain": [
|
417 |
" date zone_069_temp zone_069_fan_spd zone_068_temp \\\n",
|
418 |
+
"438785 2019-01-08 20:55:00 70.9 NaN 72.4 \n",
|
419 |
+
"438786 2019-01-08 20:56:00 70.9 NaN 72.4 \n",
|
420 |
+
"438787 2019-01-08 20:57:00 70.9 NaN 72.4 \n",
|
421 |
+
"438788 2019-01-08 20:58:00 70.9 NaN 72.4 \n",
|
422 |
+
"438789 2019-01-08 20:59:00 70.9 NaN 72.4 \n",
|
423 |
"... ... ... ... ... \n",
|
424 |
"2072148 2020-12-31 23:57:00 68.8 20.0 71.7 \n",
|
425 |
"2072149 2020-12-31 23:58:00 68.8 20.0 71.7 \n",
|
|
|
428 |
"2072152 2020-12-31 23:59:00 68.8 20.0 71.7 \n",
|
429 |
"\n",
|
430 |
" zone_068_fan_spd zone_067_temp zone_067_fan_spd zone_066_temp \\\n",
|
431 |
+
"438785 20.0 70.2 NaN 70.9 \n",
|
432 |
+
"438786 20.0 70.2 NaN 70.9 \n",
|
433 |
+
"438787 20.0 70.2 NaN 70.9 \n",
|
434 |
+
"438788 20.0 70.2 NaN 70.9 \n",
|
435 |
+
"438789 20.0 70.2 NaN 70.9 \n",
|
436 |
"... ... ... ... ... \n",
|
437 |
"2072148 20.0 70.4 20.0 68.6 \n",
|
438 |
"2072149 20.0 70.4 20.0 68.6 \n",
|
|
|
440 |
"2072151 20.0 70.4 20.0 68.6 \n",
|
441 |
"2072152 20.0 70.4 20.0 68.6 \n",
|
442 |
"\n",
|
443 |
+
" zone_066_fan_spd zone_042_temp ... zone_038_heating_sp \\\n",
|
444 |
+
"438785 NaN 72.3 ... 72.0 \n",
|
445 |
+
"438786 NaN 72.3 ... 72.0 \n",
|
446 |
+
"438787 NaN 72.3 ... 72.0 \n",
|
447 |
+
"438788 NaN 72.3 ... 72.0 \n",
|
448 |
+
"438789 NaN 72.3 ... 72.0 \n",
|
449 |
"... ... ... ... ... \n",
|
450 |
+
"2072148 35.0 71.4 ... 71.0 \n",
|
451 |
+
"2072149 35.0 71.4 ... 71.0 \n",
|
452 |
+
"2072150 35.0 71.4 ... 71.0 \n",
|
453 |
+
"2072151 35.0 71.4 ... 71.0 \n",
|
454 |
+
"2072152 35.0 71.4 ... 71.0 \n",
|
455 |
"\n",
|
456 |
+
" zone_037_cooling_sp zone_037_heating_sp zone_036_cooling_sp \\\n",
|
457 |
+
"438785 73.0 70.0 75.0 \n",
|
458 |
+
"438786 73.0 70.0 75.0 \n",
|
459 |
+
"438787 73.0 70.0 75.0 \n",
|
460 |
+
"438788 73.0 70.0 75.0 \n",
|
461 |
+
"438789 73.0 70.0 75.0 \n",
|
462 |
"... ... ... ... \n",
|
463 |
+
"2072148 74.0 68.0 74.0 \n",
|
464 |
+
"2072149 74.0 68.0 74.0 \n",
|
465 |
+
"2072150 74.0 68.0 74.0 \n",
|
466 |
+
"2072151 74.0 68.0 74.0 \n",
|
467 |
+
"2072152 74.0 68.0 74.0 \n",
|
468 |
"\n",
|
469 |
+
" zone_036_heating_sp air_temp_set_1 air_temp_set_2 \\\n",
|
470 |
+
"438785 72.0 12.850 12.930 \n",
|
471 |
+
"438786 72.0 12.850 12.930 \n",
|
472 |
+
"438787 72.0 12.850 12.930 \n",
|
473 |
+
"438788 72.0 12.850 12.930 \n",
|
474 |
+
"438789 72.0 12.850 12.930 \n",
|
475 |
"... ... ... ... \n",
|
476 |
+
"2072148 68.0 13.994 13.528 \n",
|
477 |
+
"2072149 68.0 13.994 13.528 \n",
|
478 |
+
"2072150 68.0 13.994 13.528 \n",
|
479 |
+
"2072151 68.0 13.994 13.528 \n",
|
480 |
+
"2072152 68.0 13.994 13.528 \n",
|
481 |
"\n",
|
482 |
" dew_point_temperature_set_1d relative_humidity_set_1 \\\n",
|
483 |
+
"438785 9.10 78.15 \n",
|
484 |
+
"438786 9.10 78.15 \n",
|
485 |
+
"438787 9.10 78.15 \n",
|
486 |
+
"438788 9.10 78.15 \n",
|
487 |
+
"438789 9.10 78.15 \n",
|
488 |
"... ... ... \n",
|
489 |
"2072148 4.11 51.61 \n",
|
490 |
"2072149 4.11 51.61 \n",
|
|
|
493 |
"2072152 4.11 51.61 \n",
|
494 |
"\n",
|
495 |
" solar_radiation_set_1 \n",
|
496 |
+
"438785 48.7 \n",
|
497 |
+
"438786 48.7 \n",
|
498 |
+
"438787 48.7 \n",
|
499 |
+
"438788 48.7 \n",
|
500 |
+
"438789 48.7 \n",
|
501 |
"... ... \n",
|
502 |
"2072148 188.8 \n",
|
503 |
"2072149 188.8 \n",
|
|
|
505 |
"2072151 188.8 \n",
|
506 |
"2072152 188.8 \n",
|
507 |
"\n",
|
508 |
+
"[1633368 rows x 46 columns]"
|
509 |
]
|
510 |
},
|
511 |
+
"execution_count": 5,
|
512 |
"metadata": {},
|
513 |
"output_type": "execute_result"
|
514 |
}
|
|
|
519 |
},
|
520 |
{
|
521 |
"cell_type": "code",
|
522 |
+
"execution_count": 6,
|
523 |
"metadata": {},
|
524 |
"outputs": [
|
525 |
{
|
526 |
"data": {
|
527 |
"text/plain": [
|
528 |
+
"[]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
]
|
530 |
},
|
531 |
+
"execution_count": 6,
|
532 |
"metadata": {},
|
533 |
"output_type": "execute_result"
|
534 |
}
|
535 |
],
|
536 |
"source": [
|
537 |
+
"testdataset_df = df_filtered[(df_filtered.date.dt.date >date(2020, 3, 1)) & (df_filtered.date.dt.date <date(2020,7, 1))]\n",
|
538 |
"\n",
|
539 |
"# traindataset_df = df_filtered[ (df_filtered.date.dt.date >date(2019, 11, 8))]\n",
|
540 |
"\n",
|
541 |
+
"traindataset_df = df_filtered[(df_filtered.date.dt.date >date(2019, 3, 1)) & (df_filtered.date.dt.date <date(2020, 3, 1)) | (df_filtered.date.dt.date >date(2020, 7, 1)) & (df_filtered.date.dt.date <date(2020, 12, 1))]\n",
|
542 |
+
"testdataset = testdataset_df.drop(columns=[\"date\"]).values\n",
|
543 |
+
"traindataset = traindataset_df.drop(columns=[\"date\"]).values\n",
|
544 |
"\n",
|
545 |
"columns_with_na = traindataset_df.columns[traindataset_df.isna().any()].tolist()\n",
|
546 |
"columns_with_na"
|
|
|
548 |
},
|
549 |
{
|
550 |
"cell_type": "code",
|
551 |
+
"execution_count": 7,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
"metadata": {},
|
553 |
"outputs": [
|
554 |
{
|
|
|
565 |
},
|
566 |
{
|
567 |
"cell_type": "code",
|
568 |
+
"execution_count": 8,
|
569 |
"metadata": {},
|
570 |
"outputs": [
|
571 |
{
|
572 |
"data": {
|
573 |
"text/plain": [
|
574 |
+
"(1073512, 391818)"
|
575 |
]
|
576 |
},
|
577 |
+
"execution_count": 8,
|
578 |
"metadata": {},
|
579 |
"output_type": "execute_result"
|
580 |
}
|
|
|
585 |
},
|
586 |
{
|
587 |
"cell_type": "code",
|
588 |
+
"execution_count": 9,
|
589 |
"metadata": {},
|
590 |
"outputs": [],
|
591 |
"source": [
|
|
|
599 |
},
|
600 |
{
|
601 |
"cell_type": "code",
|
602 |
+
"execution_count": 10,
|
603 |
"metadata": {},
|
604 |
"outputs": [
|
605 |
{
|
606 |
"data": {
|
607 |
"text/plain": [
|
608 |
+
"(1073512, 45)"
|
609 |
]
|
610 |
},
|
611 |
+
"execution_count": 10,
|
612 |
"metadata": {},
|
613 |
"output_type": "execute_result"
|
614 |
}
|
|
|
619 |
},
|
620 |
{
|
621 |
"cell_type": "code",
|
622 |
+
"execution_count": 11,
|
623 |
"metadata": {},
|
624 |
"outputs": [],
|
625 |
"source": [
|
|
|
630 |
" Y = []\n",
|
631 |
" for i in range(len(dataset) - time_step - 1):\n",
|
632 |
" x.append(dataset[i:(i+time_step),:])\n",
|
633 |
+
" Y.append(dataset[i+time_step,0:23])\n",
|
634 |
" x= np.array(x)\n",
|
635 |
" Y = np.array(Y)\n",
|
636 |
" return x,Y\n",
|
|
|
642 |
},
|
643 |
{
|
644 |
"cell_type": "code",
|
645 |
+
"execution_count": 12,
|
646 |
"metadata": {},
|
647 |
"outputs": [
|
648 |
{
|
649 |
"data": {
|
650 |
"text/plain": [
|
651 |
+
"((1073481, 30, 45), (1073481, 23))"
|
652 |
]
|
653 |
},
|
654 |
+
"execution_count": 12,
|
655 |
"metadata": {},
|
656 |
"output_type": "execute_result"
|
657 |
}
|
|
|
662 |
},
|
663 |
{
|
664 |
"cell_type": "code",
|
665 |
+
"execution_count": 13,
|
666 |
"metadata": {},
|
667 |
"outputs": [
|
668 |
{
|
|
|
670 |
"output_type": "stream",
|
671 |
"text": [
|
672 |
"Epoch 1/5\n",
|
673 |
+
"8387/8387 [==============================] - ETA: 0s - loss: 0.0178\n",
|
674 |
+
"Epoch 1: val_loss improved from inf to 0.42313, saving model to lstm_vav_01.tf\n",
|
675 |
"INFO:tensorflow:Assets written to: lstm_vav_01.tf\\assets\n"
|
676 |
]
|
677 |
},
|
|
|
686 |
"name": "stdout",
|
687 |
"output_type": "stream",
|
688 |
"text": [
|
689 |
+
"8387/8387 [==============================] - 307s 36ms/step - loss: 0.0178 - val_loss: 0.4231\n",
|
690 |
"Epoch 2/5\n",
|
691 |
+
"8387/8387 [==============================] - ETA: 0s - loss: 0.0032\n",
|
692 |
+
"Epoch 2: val_loss improved from 0.42313 to 0.40364, saving model to lstm_vav_01.tf\n",
|
693 |
"INFO:tensorflow:Assets written to: lstm_vav_01.tf\\assets\n"
|
694 |
]
|
695 |
},
|
|
|
704 |
"name": "stdout",
|
705 |
"output_type": "stream",
|
706 |
"text": [
|
707 |
+
"8387/8387 [==============================] - 274s 33ms/step - loss: 0.0032 - val_loss: 0.4036\n",
|
708 |
"Epoch 3/5\n",
|
709 |
+
" 259/8387 [..............................] - ETA: 4:02 - loss: 0.0028"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
710 |
]
|
711 |
},
|
712 |
{
|
713 |
+
"ename": "KeyboardInterrupt",
|
714 |
+
"evalue": "",
|
715 |
+
"output_type": "error",
|
716 |
+
"traceback": [
|
717 |
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
718 |
+
"\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
|
719 |
+
"Cell \u001b[1;32mIn[13], line 11\u001b[0m\n\u001b[0;32m 9\u001b[0m checkpoint_path \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlstm_vav_01.tf\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 10\u001b[0m checkpoint_callback \u001b[38;5;241m=\u001b[39m ModelCheckpoint(filepath\u001b[38;5;241m=\u001b[39mcheckpoint_path, monitor\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mval_loss\u001b[39m\u001b[38;5;124m'\u001b[39m, verbose\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m, save_best_only\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, mode\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmin\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m---> 11\u001b[0m \u001b[43mmodel\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfit\u001b[49m\u001b[43m(\u001b[49m\u001b[43mX_train\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43my_train\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalidation_data\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mX_test\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43my_test\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mepochs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m5\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbatch_size\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m128\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mverbose\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[43mcheckpoint_callback\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n",
|
720 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\keras\\src\\utils\\traceback_utils.py:65\u001b[0m, in \u001b[0;36mfilter_traceback.<locals>.error_handler\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 63\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 64\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m---> 65\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 66\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 67\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m _process_traceback_frames(e\u001b[38;5;241m.\u001b[39m__traceback__)\n",
|
721 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\keras\\src\\engine\\training.py:1742\u001b[0m, in \u001b[0;36mModel.fit\u001b[1;34m(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)\u001b[0m\n\u001b[0;32m 1734\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m tf\u001b[38;5;241m.\u001b[39mprofiler\u001b[38;5;241m.\u001b[39mexperimental\u001b[38;5;241m.\u001b[39mTrace(\n\u001b[0;32m 1735\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtrain\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 1736\u001b[0m epoch_num\u001b[38;5;241m=\u001b[39mepoch,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 1739\u001b[0m _r\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m,\n\u001b[0;32m 1740\u001b[0m ):\n\u001b[0;32m 1741\u001b[0m callbacks\u001b[38;5;241m.\u001b[39mon_train_batch_begin(step)\n\u001b[1;32m-> 1742\u001b[0m tmp_logs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtrain_function\u001b[49m\u001b[43m(\u001b[49m\u001b[43miterator\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1743\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m data_handler\u001b[38;5;241m.\u001b[39mshould_sync:\n\u001b[0;32m 1744\u001b[0m context\u001b[38;5;241m.\u001b[39masync_wait()\n",
|
722 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\util\\traceback_utils.py:150\u001b[0m, in \u001b[0;36mfilter_traceback.<locals>.error_handler\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 148\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 149\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 150\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 151\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 152\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m _process_traceback_frames(e\u001b[38;5;241m.\u001b[39m__traceback__)\n",
|
723 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\polymorphic_function\\polymorphic_function.py:825\u001b[0m, in \u001b[0;36mFunction.__call__\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m 822\u001b[0m compiler \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mxla\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_jit_compile \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnonXla\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 824\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m OptionalXlaContext(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_jit_compile):\n\u001b[1;32m--> 825\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 827\u001b[0m new_tracing_count \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mexperimental_get_tracing_count()\n\u001b[0;32m 828\u001b[0m without_tracing \u001b[38;5;241m=\u001b[39m (tracing_count \u001b[38;5;241m==\u001b[39m new_tracing_count)\n",
|
724 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\polymorphic_function\\polymorphic_function.py:857\u001b[0m, in \u001b[0;36mFunction._call\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m 854\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_lock\u001b[38;5;241m.\u001b[39mrelease()\n\u001b[0;32m 855\u001b[0m \u001b[38;5;66;03m# In this case we have created variables on the first call, so we run the\u001b[39;00m\n\u001b[0;32m 856\u001b[0m \u001b[38;5;66;03m# defunned version which is guaranteed to never create variables.\u001b[39;00m\n\u001b[1;32m--> 857\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_no_variable_creation_fn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# pylint: disable=not-callable\u001b[39;00m\n\u001b[0;32m 858\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_variable_creation_fn \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 859\u001b[0m \u001b[38;5;66;03m# Release the lock early so that multiple threads can perform the call\u001b[39;00m\n\u001b[0;32m 860\u001b[0m \u001b[38;5;66;03m# in parallel.\u001b[39;00m\n\u001b[0;32m 861\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_lock\u001b[38;5;241m.\u001b[39mrelease()\n",
|
725 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\polymorphic_function\\tracing_compiler.py:148\u001b[0m, in \u001b[0;36mTracingCompiler.__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 145\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_lock:\n\u001b[0;32m 146\u001b[0m (concrete_function,\n\u001b[0;32m 147\u001b[0m filtered_flat_args) \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_maybe_define_function(args, kwargs)\n\u001b[1;32m--> 148\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mconcrete_function\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_flat\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 149\u001b[0m \u001b[43m \u001b[49m\u001b[43mfiltered_flat_args\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcaptured_inputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconcrete_function\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcaptured_inputs\u001b[49m\u001b[43m)\u001b[49m\n",
|
726 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\polymorphic_function\\monomorphic_function.py:1349\u001b[0m, in \u001b[0;36mConcreteFunction._call_flat\u001b[1;34m(self, args, captured_inputs)\u001b[0m\n\u001b[0;32m 1345\u001b[0m possible_gradient_type \u001b[38;5;241m=\u001b[39m gradients_util\u001b[38;5;241m.\u001b[39mPossibleTapeGradientTypes(args)\n\u001b[0;32m 1346\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (possible_gradient_type \u001b[38;5;241m==\u001b[39m gradients_util\u001b[38;5;241m.\u001b[39mPOSSIBLE_GRADIENT_TYPES_NONE\n\u001b[0;32m 1347\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m executing_eagerly):\n\u001b[0;32m 1348\u001b[0m \u001b[38;5;66;03m# No tape is watching; skip to running the function.\u001b[39;00m\n\u001b[1;32m-> 1349\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_build_call_outputs(\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_inference_function\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m)\u001b[49m)\n\u001b[0;32m 1350\u001b[0m forward_backward \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_select_forward_and_backward_functions(\n\u001b[0;32m 1351\u001b[0m args,\n\u001b[0;32m 1352\u001b[0m possible_gradient_type,\n\u001b[0;32m 1353\u001b[0m executing_eagerly)\n\u001b[0;32m 1354\u001b[0m forward_function, args_with_tangents \u001b[38;5;241m=\u001b[39m forward_backward\u001b[38;5;241m.\u001b[39mforward()\n",
|
727 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\polymorphic_function\\atomic_function.py:196\u001b[0m, in \u001b[0;36mAtomicFunction.__call__\u001b[1;34m(self, *args)\u001b[0m\n\u001b[0;32m 194\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m record\u001b[38;5;241m.\u001b[39mstop_recording():\n\u001b[0;32m 195\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_bound_context\u001b[38;5;241m.\u001b[39mexecuting_eagerly():\n\u001b[1;32m--> 196\u001b[0m outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_bound_context\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcall_function\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 197\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 198\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mlist\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43margs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 199\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunction_type\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mflat_outputs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 200\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 201\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 202\u001b[0m outputs \u001b[38;5;241m=\u001b[39m make_call_op_in_graph(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;28mlist\u001b[39m(args))\n",
|
728 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\context.py:1457\u001b[0m, in \u001b[0;36mContext.call_function\u001b[1;34m(self, name, tensor_inputs, num_outputs)\u001b[0m\n\u001b[0;32m 1455\u001b[0m cancellation_context \u001b[38;5;241m=\u001b[39m cancellation\u001b[38;5;241m.\u001b[39mcontext()\n\u001b[0;32m 1456\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m cancellation_context \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m-> 1457\u001b[0m outputs \u001b[38;5;241m=\u001b[39m \u001b[43mexecute\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexecute\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 1458\u001b[0m \u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdecode\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mutf-8\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1459\u001b[0m \u001b[43m \u001b[49m\u001b[43mnum_outputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnum_outputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1460\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtensor_inputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1461\u001b[0m \u001b[43m \u001b[49m\u001b[43mattrs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mattrs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1462\u001b[0m \u001b[43m \u001b[49m\u001b[43mctx\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1463\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1464\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 1465\u001b[0m outputs \u001b[38;5;241m=\u001b[39m execute\u001b[38;5;241m.\u001b[39mexecute_with_cancellation(\n\u001b[0;32m 1466\u001b[0m name\u001b[38;5;241m.\u001b[39mdecode(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mutf-8\u001b[39m\u001b[38;5;124m\"\u001b[39m),\n\u001b[0;32m 1467\u001b[0m num_outputs\u001b[38;5;241m=\u001b[39mnum_outputs,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 1471\u001b[0m cancellation_manager\u001b[38;5;241m=\u001b[39mcancellation_context,\n\u001b[0;32m 1472\u001b[0m )\n",
|
729 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\execute.py:53\u001b[0m, in \u001b[0;36mquick_execute\u001b[1;34m(op_name, num_outputs, inputs, attrs, ctx, name)\u001b[0m\n\u001b[0;32m 51\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 52\u001b[0m ctx\u001b[38;5;241m.\u001b[39mensure_initialized()\n\u001b[1;32m---> 53\u001b[0m tensors \u001b[38;5;241m=\u001b[39m \u001b[43mpywrap_tfe\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mTFE_Py_Execute\u001b[49m\u001b[43m(\u001b[49m\u001b[43mctx\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_handle\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdevice_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mop_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 54\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mattrs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnum_outputs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 55\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m core\u001b[38;5;241m.\u001b[39m_NotOkStatusException \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 56\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m name \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
|
730 |
+
"\u001b[1;31mKeyboardInterrupt\u001b[0m: "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
731 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
732 |
}
|
733 |
],
|
734 |
"source": [
|
|
|
748 |
},
|
749 |
{
|
750 |
"cell_type": "code",
|
751 |
+
"execution_count": 14,
|
752 |
"metadata": {},
|
753 |
"outputs": [
|
754 |
{
|
755 |
"data": {
|
756 |
"text/plain": [
|
757 |
+
"<tensorflow.python.checkpoint.checkpoint.CheckpointLoadStatus at 0x2a4b2344610>"
|
758 |
]
|
759 |
},
|
760 |
+
"execution_count": 14,
|
761 |
"metadata": {},
|
762 |
"output_type": "execute_result"
|
763 |
}
|
|
|
768 |
},
|
769 |
{
|
770 |
"cell_type": "code",
|
771 |
+
"execution_count": 15,
|
772 |
"metadata": {},
|
773 |
"outputs": [
|
774 |
{
|
775 |
"name": "stdout",
|
776 |
"output_type": "stream",
|
777 |
"text": [
|
778 |
+
"12244/12244 [==============================] - 58s 5ms/step\n"
|
779 |
]
|
780 |
}
|
781 |
],
|
|
|
785 |
},
|
786 |
{
|
787 |
"cell_type": "code",
|
788 |
+
"execution_count": 16,
|
789 |
"metadata": {},
|
790 |
"outputs": [
|
791 |
{
|
792 |
"data": {
|
793 |
"text/plain": [
|
794 |
+
"Index(['date', 'zone_069_temp', 'zone_069_fan_spd', 'zone_068_temp',\n",
|
795 |
+
" 'zone_068_fan_spd', 'zone_067_temp', 'zone_067_fan_spd',\n",
|
796 |
+
" 'zone_066_temp', 'zone_066_fan_spd', 'zone_042_temp',\n",
|
797 |
+
" 'zone_042_fan_spd', 'zone_041_temp', 'zone_041_fan_spd',\n",
|
798 |
+
" 'zone_040_temp', 'zone_040_fan_spd', 'zone_039_temp',\n",
|
799 |
+
" 'zone_039_fan_spd', 'zone_038_temp', 'zone_038_fan_spd',\n",
|
800 |
+
" 'zone_037_temp', 'zone_037_fan_spd', 'zone_036_temp',\n",
|
801 |
+
" 'zone_036_fan_spd', 'zone_069_cooling_sp', 'zone_069_heating_sp',\n",
|
802 |
+
" 'zone_067_cooling_sp', 'zone_067_heating_sp', 'zone_066_cooling_sp',\n",
|
803 |
+
" 'zone_066_heating_sp', 'zone_042_cooling_sp', 'zone_042_heating_sp',\n",
|
804 |
+
" 'zone_041_cooling_sp', 'zone_041_heating_sp', 'zone_039_cooling_sp',\n",
|
805 |
+
" 'zone_039_heating_sp', 'zone_038_cooling_sp', 'zone_038_heating_sp',\n",
|
806 |
+
" 'zone_037_cooling_sp', 'zone_037_heating_sp', 'zone_036_cooling_sp',\n",
|
807 |
+
" 'zone_036_heating_sp', 'air_temp_set_1', 'air_temp_set_2',\n",
|
808 |
+
" 'dew_point_temperature_set_1d', 'relative_humidity_set_1',\n",
|
809 |
+
" 'solar_radiation_set_1'],\n",
|
810 |
+
" dtype='object')"
|
811 |
]
|
812 |
},
|
813 |
+
"execution_count": 16,
|
814 |
"metadata": {},
|
815 |
"output_type": "execute_result"
|
816 |
}
|
817 |
],
|
818 |
"source": [
|
819 |
+
"traindataset_df.columns"
|
|
|
820 |
]
|
821 |
},
|
822 |
{
|
823 |
"cell_type": "code",
|
824 |
+
"execution_count": 37,
|
825 |
"metadata": {},
|
826 |
"outputs": [],
|
827 |
"source": [
|
828 |
"%matplotlib qt\n",
|
829 |
+
"plt.figure()\n",
|
830 |
"var = 1\n",
|
831 |
"plt.plot(y_test[:,var], label='Original Testing Data', color='blue')\n",
|
832 |
"plt.plot(test_predict1[:,var], label='Predicted Testing Data', color='red',alpha=0.8)\n",
|
|
|
852 |
"import matplotlib.pyplot as plt\n",
|
853 |
"from sklearn.decomposition import PCA\n",
|
854 |
"\n",
|
855 |
+
"\n",
|
856 |
"# Generating random data for demonstration\n",
|
857 |
"np.random.seed(0)\n",
|
858 |
"X = test_predict1 - y_test\n",
|
|
|
881 |
},
|
882 |
{
|
883 |
"cell_type": "code",
|
884 |
+
"execution_count": null,
|
885 |
"metadata": {},
|
886 |
+
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
887 |
"source": [
|
888 |
"from sklearn.cluster import KMeans\n",
|
889 |
"import numpy as np\n",
|
890 |
"import matplotlib.pyplot as plt\n",
|
891 |
+
"from sklearn.decomposition import PCA\n",
|
892 |
+
"\n",
|
893 |
"# Generating random data for demonstration\n",
|
894 |
"np.random.seed(0)\n",
|
895 |
"X = (test_predict1 - y_test)\n",
|
|
|
922 |
},
|
923 |
{
|
924 |
"cell_type": "code",
|
925 |
+
"execution_count": 19,
|
926 |
"metadata": {},
|
927 |
"outputs": [],
|
928 |
"source": [
|
|
|
973 |
},
|
974 |
{
|
975 |
"cell_type": "code",
|
976 |
+
"execution_count": 21,
|
977 |
"metadata": {},
|
978 |
"outputs": [],
|
979 |
"source": [
|
|
|
987 |
"X = processed_data\n",
|
988 |
"\n",
|
989 |
"# Creating the GMM instance with desired number of clusters\n",
|
990 |
+
"gmm = GaussianMixture(n_components=2, init_params='k-means++')\n",
|
991 |
"\n",
|
992 |
"# Fitting the model to the data\n",
|
993 |
"gmm.fit(X)\n",
|
|
|
1011 |
},
|
1012 |
{
|
1013 |
"cell_type": "code",
|
1014 |
+
"execution_count": 38,
|
1015 |
"metadata": {},
|
1016 |
"outputs": [],
|
1017 |
"source": [
|
|
|
1020 |
"import matplotlib.pyplot as plt\n",
|
1021 |
"# Generating random data for demonstration\n",
|
1022 |
"np.random.seed(0)\n",
|
1023 |
+
"X = test_predict1 - y_test \n",
|
|
|
1024 |
"\n",
|
1025 |
+
"kmeans = KMeans(n_clusters=2)\n",
|
1026 |
"\n",
|
1027 |
"kmeans.fit(X)\n",
|
1028 |
"\n",
|
|
|
1038 |
"labels = kmeans.labels_\n",
|
1039 |
"\n",
|
1040 |
"# Plotting the data points and cluster centers\n",
|
1041 |
+
"plt.figure()\n",
|
1042 |
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
1043 |
"plt.scatter(centroids[:, 0], centroids[:, 1], marker='x', c='red', s=200, linewidths=2)\n",
|
1044 |
+
"plt.text(centroids[0,0], centroids[0,1], 'Normal', fontsize=12, color='red')\n",
|
1045 |
+
"plt.text(centroids[1,0], centroids[1,1], 'Anomaly', fontsize=12, color='red')\n",
|
1046 |
"plt.title('KMeans Clustering')\n",
|
1047 |
"plt.xlabel('Feature 1')\n",
|
1048 |
"plt.ylabel('Feature 2')\n",
|
|
|
1051 |
},
|
1052 |
{
|
1053 |
"cell_type": "code",
|
1054 |
+
"execution_count": 29,
|
1055 |
"metadata": {},
|
1056 |
+
"outputs": [
|
1057 |
+
{
|
1058 |
+
"data": {
|
1059 |
+
"text/plain": [
|
1060 |
+
"329810"
|
1061 |
+
]
|
1062 |
+
},
|
1063 |
+
"execution_count": 29,
|
1064 |
+
"metadata": {},
|
1065 |
+
"output_type": "execute_result"
|
1066 |
+
}
|
1067 |
+
],
|
1068 |
+
"source": [
|
1069 |
+
"sum(labels==0)"
|
1070 |
+
]
|
1071 |
}
|
1072 |
],
|
1073 |
"metadata": {
|
physLSTM/lstm_vav_rtu2.ipynb
ADDED
@@ -0,0 +1,1075 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import pandas as pd \n",
|
10 |
+
"from datetime import datetime \n",
|
11 |
+
"from datetime import date\n",
|
12 |
+
"import matplotlib.pyplot as plt\n",
|
13 |
+
"import numpy as np\n",
|
14 |
+
"import pandas as pd\n",
|
15 |
+
"from keras.models import Sequential\n",
|
16 |
+
"from keras.layers import LSTM, Dense\n",
|
17 |
+
"from sklearn.model_selection import train_test_split\n",
|
18 |
+
"from sklearn.preprocessing import MinMaxScaler,StandardScaler\n",
|
19 |
+
"from keras.callbacks import ModelCheckpoint\n",
|
20 |
+
"import tensorflow as tf"
|
21 |
+
]
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"cell_type": "code",
|
25 |
+
"execution_count": 2,
|
26 |
+
"metadata": {},
|
27 |
+
"outputs": [],
|
28 |
+
"source": [
|
29 |
+
"merged = pd.read_csv(r'../data/long_merge.csv')"
|
30 |
+
]
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"cell_type": "code",
|
34 |
+
"execution_count": 3,
|
35 |
+
"metadata": {},
|
36 |
+
"outputs": [],
|
37 |
+
"source": [
|
38 |
+
"zones = [72, 71, 63, 62, 60, 59, 58,57, 50, 49, 44, 43, 35, 34, 33, 32, 31, 30, 29, 28, ]\n",
|
39 |
+
"rtus = [2]\n",
|
40 |
+
"cols = []\n",
|
41 |
+
"\n",
|
42 |
+
"for zone in zones:\n",
|
43 |
+
" for column in merged.columns:\n",
|
44 |
+
" if f\"zone_0{zone}\" in column and 'co2' not in column and \"hw_valve\" not in column and \"cooling_sp\" not in column and \"heating_sp\" not in column:\n",
|
45 |
+
" cols.append(column)\n",
|
46 |
+
"\n",
|
47 |
+
"for zone in zones:\n",
|
48 |
+
" for column in merged.columns:\n",
|
49 |
+
" if f\"zone_0{zone}\" in column: \n",
|
50 |
+
" if \"cooling_sp\" in column or \"heating_sp\" in column:\n",
|
51 |
+
" cols.append(column)\n",
|
52 |
+
"# for rtu in rtus:\n",
|
53 |
+
"# for column in merged.columns:\n",
|
54 |
+
"# if f\"rtu_00{rtu}_fltrd_sa\" in column:\n",
|
55 |
+
"# cols.append(column)\n",
|
56 |
+
"cols =['date'] + cols + ['air_temp_set_1',\n",
|
57 |
+
" 'air_temp_set_2',\n",
|
58 |
+
" 'dew_point_temperature_set_1d',\n",
|
59 |
+
" 'relative_humidity_set_1',\n",
|
60 |
+
" 'solar_radiation_set_1']\n",
|
61 |
+
"input_dataset = merged[cols]"
|
62 |
+
]
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"cell_type": "code",
|
66 |
+
"execution_count": 4,
|
67 |
+
"metadata": {},
|
68 |
+
"outputs": [
|
69 |
+
{
|
70 |
+
"name": "stderr",
|
71 |
+
"output_type": "stream",
|
72 |
+
"text": [
|
73 |
+
"C:\\Users\\arbal\\AppData\\Local\\Temp\\ipykernel_38868\\1855433847.py:1: SettingWithCopyWarning: \n",
|
74 |
+
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
75 |
+
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
76 |
+
"\n",
|
77 |
+
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
78 |
+
" input_dataset['date'] = pd.to_datetime(input_dataset['date'], format = \"%Y-%m-%d %H:%M:%S\")\n"
|
79 |
+
]
|
80 |
+
}
|
81 |
+
],
|
82 |
+
"source": [
|
83 |
+
"input_dataset['date'] = pd.to_datetime(input_dataset['date'], format = \"%Y-%m-%d %H:%M:%S\")\n",
|
84 |
+
"df_filtered = input_dataset[ (input_dataset.date.dt.date >date(2019, 3, 1)) & (input_dataset.date.dt.date< date(2021, 1, 1))]\n",
|
85 |
+
"\n",
|
86 |
+
"if df_filtered.isna().any().any():\n",
|
87 |
+
" print(\"There are NA values in the DataFrame columns.\")"
|
88 |
+
]
|
89 |
+
},
|
90 |
+
{
|
91 |
+
"cell_type": "code",
|
92 |
+
"execution_count": 5,
|
93 |
+
"metadata": {},
|
94 |
+
"outputs": [
|
95 |
+
{
|
96 |
+
"data": {
|
97 |
+
"text/html": [
|
98 |
+
"<div>\n",
|
99 |
+
"<style scoped>\n",
|
100 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
101 |
+
" vertical-align: middle;\n",
|
102 |
+
" }\n",
|
103 |
+
"\n",
|
104 |
+
" .dataframe tbody tr th {\n",
|
105 |
+
" vertical-align: top;\n",
|
106 |
+
" }\n",
|
107 |
+
"\n",
|
108 |
+
" .dataframe thead th {\n",
|
109 |
+
" text-align: right;\n",
|
110 |
+
" }\n",
|
111 |
+
"</style>\n",
|
112 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
113 |
+
" <thead>\n",
|
114 |
+
" <tr style=\"text-align: right;\">\n",
|
115 |
+
" <th></th>\n",
|
116 |
+
" <th>date</th>\n",
|
117 |
+
" <th>zone_072_temp</th>\n",
|
118 |
+
" <th>zone_072_fan_spd</th>\n",
|
119 |
+
" <th>zone_071_temp</th>\n",
|
120 |
+
" <th>zone_071_fan_spd</th>\n",
|
121 |
+
" <th>zone_063_temp</th>\n",
|
122 |
+
" <th>zone_063_fan_spd</th>\n",
|
123 |
+
" <th>zone_062_temp</th>\n",
|
124 |
+
" <th>zone_062_fan_spd</th>\n",
|
125 |
+
" <th>zone_059_temp</th>\n",
|
126 |
+
" <th>...</th>\n",
|
127 |
+
" <th>zone_035_heating_sp</th>\n",
|
128 |
+
" <th>zone_032_cooling_sp</th>\n",
|
129 |
+
" <th>zone_032_heating_sp</th>\n",
|
130 |
+
" <th>zone_030_cooling_sp</th>\n",
|
131 |
+
" <th>zone_030_heating_sp</th>\n",
|
132 |
+
" <th>air_temp_set_1</th>\n",
|
133 |
+
" <th>air_temp_set_2</th>\n",
|
134 |
+
" <th>dew_point_temperature_set_1d</th>\n",
|
135 |
+
" <th>relative_humidity_set_1</th>\n",
|
136 |
+
" <th>solar_radiation_set_1</th>\n",
|
137 |
+
" </tr>\n",
|
138 |
+
" </thead>\n",
|
139 |
+
" <tbody>\n",
|
140 |
+
" <tr>\n",
|
141 |
+
" <th>511205</th>\n",
|
142 |
+
" <td>2019-03-02 00:00:00</td>\n",
|
143 |
+
" <td>71.2</td>\n",
|
144 |
+
" <td>40.0</td>\n",
|
145 |
+
" <td>71.5</td>\n",
|
146 |
+
" <td>20.0</td>\n",
|
147 |
+
" <td>72.3</td>\n",
|
148 |
+
" <td>20.0</td>\n",
|
149 |
+
" <td>72.9</td>\n",
|
150 |
+
" <td>55.0</td>\n",
|
151 |
+
" <td>71.9</td>\n",
|
152 |
+
" <td>...</td>\n",
|
153 |
+
" <td>70.0</td>\n",
|
154 |
+
" <td>74.000000</td>\n",
|
155 |
+
" <td>68.0</td>\n",
|
156 |
+
" <td>73.0</td>\n",
|
157 |
+
" <td>67.0</td>\n",
|
158 |
+
" <td>11.590</td>\n",
|
159 |
+
" <td>11.130</td>\n",
|
160 |
+
" <td>3.00</td>\n",
|
161 |
+
" <td>55.87</td>\n",
|
162 |
+
" <td>120.3</td>\n",
|
163 |
+
" </tr>\n",
|
164 |
+
" <tr>\n",
|
165 |
+
" <th>511206</th>\n",
|
166 |
+
" <td>2019-03-02 00:01:00</td>\n",
|
167 |
+
" <td>71.2</td>\n",
|
168 |
+
" <td>40.0</td>\n",
|
169 |
+
" <td>71.5</td>\n",
|
170 |
+
" <td>20.0</td>\n",
|
171 |
+
" <td>72.3</td>\n",
|
172 |
+
" <td>20.0</td>\n",
|
173 |
+
" <td>72.9</td>\n",
|
174 |
+
" <td>55.0</td>\n",
|
175 |
+
" <td>71.9</td>\n",
|
176 |
+
" <td>...</td>\n",
|
177 |
+
" <td>70.0</td>\n",
|
178 |
+
" <td>74.000000</td>\n",
|
179 |
+
" <td>68.0</td>\n",
|
180 |
+
" <td>73.0</td>\n",
|
181 |
+
" <td>67.0</td>\n",
|
182 |
+
" <td>11.590</td>\n",
|
183 |
+
" <td>11.130</td>\n",
|
184 |
+
" <td>3.00</td>\n",
|
185 |
+
" <td>55.87</td>\n",
|
186 |
+
" <td>120.3</td>\n",
|
187 |
+
" </tr>\n",
|
188 |
+
" <tr>\n",
|
189 |
+
" <th>511207</th>\n",
|
190 |
+
" <td>2019-03-02 00:02:00</td>\n",
|
191 |
+
" <td>71.2</td>\n",
|
192 |
+
" <td>40.0</td>\n",
|
193 |
+
" <td>71.5</td>\n",
|
194 |
+
" <td>20.0</td>\n",
|
195 |
+
" <td>72.3</td>\n",
|
196 |
+
" <td>20.0</td>\n",
|
197 |
+
" <td>72.6</td>\n",
|
198 |
+
" <td>55.0</td>\n",
|
199 |
+
" <td>71.9</td>\n",
|
200 |
+
" <td>...</td>\n",
|
201 |
+
" <td>70.0</td>\n",
|
202 |
+
" <td>74.000000</td>\n",
|
203 |
+
" <td>68.0</td>\n",
|
204 |
+
" <td>73.0</td>\n",
|
205 |
+
" <td>67.0</td>\n",
|
206 |
+
" <td>11.590</td>\n",
|
207 |
+
" <td>11.130</td>\n",
|
208 |
+
" <td>3.00</td>\n",
|
209 |
+
" <td>55.87</td>\n",
|
210 |
+
" <td>120.3</td>\n",
|
211 |
+
" </tr>\n",
|
212 |
+
" <tr>\n",
|
213 |
+
" <th>511208</th>\n",
|
214 |
+
" <td>2019-03-02 00:03:00</td>\n",
|
215 |
+
" <td>71.2</td>\n",
|
216 |
+
" <td>40.0</td>\n",
|
217 |
+
" <td>71.5</td>\n",
|
218 |
+
" <td>20.0</td>\n",
|
219 |
+
" <td>72.3</td>\n",
|
220 |
+
" <td>20.0</td>\n",
|
221 |
+
" <td>72.9</td>\n",
|
222 |
+
" <td>55.0</td>\n",
|
223 |
+
" <td>71.9</td>\n",
|
224 |
+
" <td>...</td>\n",
|
225 |
+
" <td>70.0</td>\n",
|
226 |
+
" <td>74.000000</td>\n",
|
227 |
+
" <td>68.0</td>\n",
|
228 |
+
" <td>73.0</td>\n",
|
229 |
+
" <td>67.0</td>\n",
|
230 |
+
" <td>11.590</td>\n",
|
231 |
+
" <td>11.130</td>\n",
|
232 |
+
" <td>3.00</td>\n",
|
233 |
+
" <td>55.87</td>\n",
|
234 |
+
" <td>120.3</td>\n",
|
235 |
+
" </tr>\n",
|
236 |
+
" <tr>\n",
|
237 |
+
" <th>511209</th>\n",
|
238 |
+
" <td>2019-03-02 00:04:00</td>\n",
|
239 |
+
" <td>71.2</td>\n",
|
240 |
+
" <td>40.0</td>\n",
|
241 |
+
" <td>71.4</td>\n",
|
242 |
+
" <td>20.0</td>\n",
|
243 |
+
" <td>72.3</td>\n",
|
244 |
+
" <td>20.0</td>\n",
|
245 |
+
" <td>72.9</td>\n",
|
246 |
+
" <td>55.0</td>\n",
|
247 |
+
" <td>71.9</td>\n",
|
248 |
+
" <td>...</td>\n",
|
249 |
+
" <td>70.0</td>\n",
|
250 |
+
" <td>74.000000</td>\n",
|
251 |
+
" <td>68.0</td>\n",
|
252 |
+
" <td>73.0</td>\n",
|
253 |
+
" <td>67.0</td>\n",
|
254 |
+
" <td>11.590</td>\n",
|
255 |
+
" <td>11.130</td>\n",
|
256 |
+
" <td>3.00</td>\n",
|
257 |
+
" <td>55.87</td>\n",
|
258 |
+
" <td>120.3</td>\n",
|
259 |
+
" </tr>\n",
|
260 |
+
" <tr>\n",
|
261 |
+
" <th>...</th>\n",
|
262 |
+
" <td>...</td>\n",
|
263 |
+
" <td>...</td>\n",
|
264 |
+
" <td>...</td>\n",
|
265 |
+
" <td>...</td>\n",
|
266 |
+
" <td>...</td>\n",
|
267 |
+
" <td>...</td>\n",
|
268 |
+
" <td>...</td>\n",
|
269 |
+
" <td>...</td>\n",
|
270 |
+
" <td>...</td>\n",
|
271 |
+
" <td>...</td>\n",
|
272 |
+
" <td>...</td>\n",
|
273 |
+
" <td>...</td>\n",
|
274 |
+
" <td>...</td>\n",
|
275 |
+
" <td>...</td>\n",
|
276 |
+
" <td>...</td>\n",
|
277 |
+
" <td>...</td>\n",
|
278 |
+
" <td>...</td>\n",
|
279 |
+
" <td>...</td>\n",
|
280 |
+
" <td>...</td>\n",
|
281 |
+
" <td>...</td>\n",
|
282 |
+
" <td>...</td>\n",
|
283 |
+
" </tr>\n",
|
284 |
+
" <tr>\n",
|
285 |
+
" <th>2072148</th>\n",
|
286 |
+
" <td>2020-12-31 23:57:00</td>\n",
|
287 |
+
" <td>69.5</td>\n",
|
288 |
+
" <td>40.0</td>\n",
|
289 |
+
" <td>71.2</td>\n",
|
290 |
+
" <td>20.0</td>\n",
|
291 |
+
" <td>68.0</td>\n",
|
292 |
+
" <td>20.0</td>\n",
|
293 |
+
" <td>67.6</td>\n",
|
294 |
+
" <td>40.0</td>\n",
|
295 |
+
" <td>67.5</td>\n",
|
296 |
+
" <td>...</td>\n",
|
297 |
+
" <td>68.0</td>\n",
|
298 |
+
" <td>72.714138</td>\n",
|
299 |
+
" <td>71.0</td>\n",
|
300 |
+
" <td>71.0</td>\n",
|
301 |
+
" <td>70.0</td>\n",
|
302 |
+
" <td>13.994</td>\n",
|
303 |
+
" <td>13.528</td>\n",
|
304 |
+
" <td>4.11</td>\n",
|
305 |
+
" <td>51.61</td>\n",
|
306 |
+
" <td>188.8</td>\n",
|
307 |
+
" </tr>\n",
|
308 |
+
" <tr>\n",
|
309 |
+
" <th>2072149</th>\n",
|
310 |
+
" <td>2020-12-31 23:58:00</td>\n",
|
311 |
+
" <td>69.5</td>\n",
|
312 |
+
" <td>40.0</td>\n",
|
313 |
+
" <td>71.3</td>\n",
|
314 |
+
" <td>20.0</td>\n",
|
315 |
+
" <td>68.0</td>\n",
|
316 |
+
" <td>20.0</td>\n",
|
317 |
+
" <td>67.6</td>\n",
|
318 |
+
" <td>40.0</td>\n",
|
319 |
+
" <td>67.5</td>\n",
|
320 |
+
" <td>...</td>\n",
|
321 |
+
" <td>68.0</td>\n",
|
322 |
+
" <td>72.714138</td>\n",
|
323 |
+
" <td>71.0</td>\n",
|
324 |
+
" <td>71.0</td>\n",
|
325 |
+
" <td>70.0</td>\n",
|
326 |
+
" <td>13.994</td>\n",
|
327 |
+
" <td>13.528</td>\n",
|
328 |
+
" <td>4.11</td>\n",
|
329 |
+
" <td>51.61</td>\n",
|
330 |
+
" <td>188.8</td>\n",
|
331 |
+
" </tr>\n",
|
332 |
+
" <tr>\n",
|
333 |
+
" <th>2072150</th>\n",
|
334 |
+
" <td>2020-12-31 23:58:00</td>\n",
|
335 |
+
" <td>69.5</td>\n",
|
336 |
+
" <td>40.0</td>\n",
|
337 |
+
" <td>71.3</td>\n",
|
338 |
+
" <td>20.0</td>\n",
|
339 |
+
" <td>68.0</td>\n",
|
340 |
+
" <td>20.0</td>\n",
|
341 |
+
" <td>67.6</td>\n",
|
342 |
+
" <td>40.0</td>\n",
|
343 |
+
" <td>67.5</td>\n",
|
344 |
+
" <td>...</td>\n",
|
345 |
+
" <td>68.0</td>\n",
|
346 |
+
" <td>72.714138</td>\n",
|
347 |
+
" <td>71.0</td>\n",
|
348 |
+
" <td>71.0</td>\n",
|
349 |
+
" <td>70.0</td>\n",
|
350 |
+
" <td>13.994</td>\n",
|
351 |
+
" <td>13.528</td>\n",
|
352 |
+
" <td>4.11</td>\n",
|
353 |
+
" <td>51.61</td>\n",
|
354 |
+
" <td>188.8</td>\n",
|
355 |
+
" </tr>\n",
|
356 |
+
" <tr>\n",
|
357 |
+
" <th>2072151</th>\n",
|
358 |
+
" <td>2020-12-31 23:59:00</td>\n",
|
359 |
+
" <td>69.5</td>\n",
|
360 |
+
" <td>40.0</td>\n",
|
361 |
+
" <td>71.5</td>\n",
|
362 |
+
" <td>20.0</td>\n",
|
363 |
+
" <td>68.0</td>\n",
|
364 |
+
" <td>20.0</td>\n",
|
365 |
+
" <td>67.6</td>\n",
|
366 |
+
" <td>40.0</td>\n",
|
367 |
+
" <td>67.5</td>\n",
|
368 |
+
" <td>...</td>\n",
|
369 |
+
" <td>68.0</td>\n",
|
370 |
+
" <td>72.714138</td>\n",
|
371 |
+
" <td>71.0</td>\n",
|
372 |
+
" <td>71.0</td>\n",
|
373 |
+
" <td>70.0</td>\n",
|
374 |
+
" <td>13.994</td>\n",
|
375 |
+
" <td>13.528</td>\n",
|
376 |
+
" <td>4.11</td>\n",
|
377 |
+
" <td>51.61</td>\n",
|
378 |
+
" <td>188.8</td>\n",
|
379 |
+
" </tr>\n",
|
380 |
+
" <tr>\n",
|
381 |
+
" <th>2072152</th>\n",
|
382 |
+
" <td>2020-12-31 23:59:00</td>\n",
|
383 |
+
" <td>69.5</td>\n",
|
384 |
+
" <td>40.0</td>\n",
|
385 |
+
" <td>71.5</td>\n",
|
386 |
+
" <td>20.0</td>\n",
|
387 |
+
" <td>68.0</td>\n",
|
388 |
+
" <td>20.0</td>\n",
|
389 |
+
" <td>67.6</td>\n",
|
390 |
+
" <td>40.0</td>\n",
|
391 |
+
" <td>67.5</td>\n",
|
392 |
+
" <td>...</td>\n",
|
393 |
+
" <td>68.0</td>\n",
|
394 |
+
" <td>72.714138</td>\n",
|
395 |
+
" <td>71.0</td>\n",
|
396 |
+
" <td>71.0</td>\n",
|
397 |
+
" <td>70.0</td>\n",
|
398 |
+
" <td>13.994</td>\n",
|
399 |
+
" <td>13.528</td>\n",
|
400 |
+
" <td>4.11</td>\n",
|
401 |
+
" <td>51.61</td>\n",
|
402 |
+
" <td>188.8</td>\n",
|
403 |
+
" </tr>\n",
|
404 |
+
" </tbody>\n",
|
405 |
+
"</table>\n",
|
406 |
+
"<p>1560948 rows × 56 columns</p>\n",
|
407 |
+
"</div>"
|
408 |
+
],
|
409 |
+
"text/plain": [
|
410 |
+
" date zone_072_temp zone_072_fan_spd zone_071_temp \\\n",
|
411 |
+
"511205 2019-03-02 00:00:00 71.2 40.0 71.5 \n",
|
412 |
+
"511206 2019-03-02 00:01:00 71.2 40.0 71.5 \n",
|
413 |
+
"511207 2019-03-02 00:02:00 71.2 40.0 71.5 \n",
|
414 |
+
"511208 2019-03-02 00:03:00 71.2 40.0 71.5 \n",
|
415 |
+
"511209 2019-03-02 00:04:00 71.2 40.0 71.4 \n",
|
416 |
+
"... ... ... ... ... \n",
|
417 |
+
"2072148 2020-12-31 23:57:00 69.5 40.0 71.2 \n",
|
418 |
+
"2072149 2020-12-31 23:58:00 69.5 40.0 71.3 \n",
|
419 |
+
"2072150 2020-12-31 23:58:00 69.5 40.0 71.3 \n",
|
420 |
+
"2072151 2020-12-31 23:59:00 69.5 40.0 71.5 \n",
|
421 |
+
"2072152 2020-12-31 23:59:00 69.5 40.0 71.5 \n",
|
422 |
+
"\n",
|
423 |
+
" zone_071_fan_spd zone_063_temp zone_063_fan_spd zone_062_temp \\\n",
|
424 |
+
"511205 20.0 72.3 20.0 72.9 \n",
|
425 |
+
"511206 20.0 72.3 20.0 72.9 \n",
|
426 |
+
"511207 20.0 72.3 20.0 72.6 \n",
|
427 |
+
"511208 20.0 72.3 20.0 72.9 \n",
|
428 |
+
"511209 20.0 72.3 20.0 72.9 \n",
|
429 |
+
"... ... ... ... ... \n",
|
430 |
+
"2072148 20.0 68.0 20.0 67.6 \n",
|
431 |
+
"2072149 20.0 68.0 20.0 67.6 \n",
|
432 |
+
"2072150 20.0 68.0 20.0 67.6 \n",
|
433 |
+
"2072151 20.0 68.0 20.0 67.6 \n",
|
434 |
+
"2072152 20.0 68.0 20.0 67.6 \n",
|
435 |
+
"\n",
|
436 |
+
" zone_062_fan_spd zone_059_temp ... zone_035_heating_sp \\\n",
|
437 |
+
"511205 55.0 71.9 ... 70.0 \n",
|
438 |
+
"511206 55.0 71.9 ... 70.0 \n",
|
439 |
+
"511207 55.0 71.9 ... 70.0 \n",
|
440 |
+
"511208 55.0 71.9 ... 70.0 \n",
|
441 |
+
"511209 55.0 71.9 ... 70.0 \n",
|
442 |
+
"... ... ... ... ... \n",
|
443 |
+
"2072148 40.0 67.5 ... 68.0 \n",
|
444 |
+
"2072149 40.0 67.5 ... 68.0 \n",
|
445 |
+
"2072150 40.0 67.5 ... 68.0 \n",
|
446 |
+
"2072151 40.0 67.5 ... 68.0 \n",
|
447 |
+
"2072152 40.0 67.5 ... 68.0 \n",
|
448 |
+
"\n",
|
449 |
+
" zone_032_cooling_sp zone_032_heating_sp zone_030_cooling_sp \\\n",
|
450 |
+
"511205 74.000000 68.0 73.0 \n",
|
451 |
+
"511206 74.000000 68.0 73.0 \n",
|
452 |
+
"511207 74.000000 68.0 73.0 \n",
|
453 |
+
"511208 74.000000 68.0 73.0 \n",
|
454 |
+
"511209 74.000000 68.0 73.0 \n",
|
455 |
+
"... ... ... ... \n",
|
456 |
+
"2072148 72.714138 71.0 71.0 \n",
|
457 |
+
"2072149 72.714138 71.0 71.0 \n",
|
458 |
+
"2072150 72.714138 71.0 71.0 \n",
|
459 |
+
"2072151 72.714138 71.0 71.0 \n",
|
460 |
+
"2072152 72.714138 71.0 71.0 \n",
|
461 |
+
"\n",
|
462 |
+
" zone_030_heating_sp air_temp_set_1 air_temp_set_2 \\\n",
|
463 |
+
"511205 67.0 11.590 11.130 \n",
|
464 |
+
"511206 67.0 11.590 11.130 \n",
|
465 |
+
"511207 67.0 11.590 11.130 \n",
|
466 |
+
"511208 67.0 11.590 11.130 \n",
|
467 |
+
"511209 67.0 11.590 11.130 \n",
|
468 |
+
"... ... ... ... \n",
|
469 |
+
"2072148 70.0 13.994 13.528 \n",
|
470 |
+
"2072149 70.0 13.994 13.528 \n",
|
471 |
+
"2072150 70.0 13.994 13.528 \n",
|
472 |
+
"2072151 70.0 13.994 13.528 \n",
|
473 |
+
"2072152 70.0 13.994 13.528 \n",
|
474 |
+
"\n",
|
475 |
+
" dew_point_temperature_set_1d relative_humidity_set_1 \\\n",
|
476 |
+
"511205 3.00 55.87 \n",
|
477 |
+
"511206 3.00 55.87 \n",
|
478 |
+
"511207 3.00 55.87 \n",
|
479 |
+
"511208 3.00 55.87 \n",
|
480 |
+
"511209 3.00 55.87 \n",
|
481 |
+
"... ... ... \n",
|
482 |
+
"2072148 4.11 51.61 \n",
|
483 |
+
"2072149 4.11 51.61 \n",
|
484 |
+
"2072150 4.11 51.61 \n",
|
485 |
+
"2072151 4.11 51.61 \n",
|
486 |
+
"2072152 4.11 51.61 \n",
|
487 |
+
"\n",
|
488 |
+
" solar_radiation_set_1 \n",
|
489 |
+
"511205 120.3 \n",
|
490 |
+
"511206 120.3 \n",
|
491 |
+
"511207 120.3 \n",
|
492 |
+
"511208 120.3 \n",
|
493 |
+
"511209 120.3 \n",
|
494 |
+
"... ... \n",
|
495 |
+
"2072148 188.8 \n",
|
496 |
+
"2072149 188.8 \n",
|
497 |
+
"2072150 188.8 \n",
|
498 |
+
"2072151 188.8 \n",
|
499 |
+
"2072152 188.8 \n",
|
500 |
+
"\n",
|
501 |
+
"[1560948 rows x 56 columns]"
|
502 |
+
]
|
503 |
+
},
|
504 |
+
"execution_count": 5,
|
505 |
+
"metadata": {},
|
506 |
+
"output_type": "execute_result"
|
507 |
+
}
|
508 |
+
],
|
509 |
+
"source": [
|
510 |
+
"df_filtered"
|
511 |
+
]
|
512 |
+
},
|
513 |
+
{
|
514 |
+
"cell_type": "code",
|
515 |
+
"execution_count": 6,
|
516 |
+
"metadata": {},
|
517 |
+
"outputs": [
|
518 |
+
{
|
519 |
+
"data": {
|
520 |
+
"text/plain": [
|
521 |
+
"[]"
|
522 |
+
]
|
523 |
+
},
|
524 |
+
"execution_count": 6,
|
525 |
+
"metadata": {},
|
526 |
+
"output_type": "execute_result"
|
527 |
+
}
|
528 |
+
],
|
529 |
+
"source": [
|
530 |
+
"testdataset_df = df_filtered[(df_filtered.date.dt.date >date(2020, 3, 1)) & (df_filtered.date.dt.date <date(2020,7, 1))]\n",
|
531 |
+
"\n",
|
532 |
+
"# traindataset_df = df_filtered[ (df_filtered.date.dt.date >date(2019, 11, 8))]\n",
|
533 |
+
"\n",
|
534 |
+
"traindataset_df = df_filtered[(df_filtered.date.dt.date >date(2019, 3, 1)) & (df_filtered.date.dt.date <date(2020, 3, 1)) | (df_filtered.date.dt.date >date(2020, 7, 1)) & (df_filtered.date.dt.date <date(2020, 12, 1))]\n",
|
535 |
+
"testdataset = testdataset_df.drop(columns=[\"date\"]).values\n",
|
536 |
+
"traindataset = traindataset_df.drop(columns=[\"date\"]).values\n",
|
537 |
+
"\n",
|
538 |
+
"columns_with_na = traindataset_df.columns[traindataset_df.isna().any()].tolist()\n",
|
539 |
+
"columns_with_na"
|
540 |
+
]
|
541 |
+
},
|
542 |
+
{
|
543 |
+
"cell_type": "code",
|
544 |
+
"execution_count": 7,
|
545 |
+
"metadata": {},
|
546 |
+
"outputs": [
|
547 |
+
{
|
548 |
+
"data": {
|
549 |
+
"text/plain": [
|
550 |
+
"Index(['date', 'zone_072_temp', 'zone_072_fan_spd', 'zone_071_temp',\n",
|
551 |
+
" 'zone_071_fan_spd', 'zone_063_temp', 'zone_063_fan_spd',\n",
|
552 |
+
" 'zone_062_temp', 'zone_062_fan_spd', 'zone_059_temp',\n",
|
553 |
+
" 'zone_059_fan_spd', 'zone_058_temp', 'zone_058_fan_spd',\n",
|
554 |
+
" 'zone_057_temp', 'zone_057_fan_spd', 'zone_049_temp',\n",
|
555 |
+
" 'zone_049_fan_spd', 'zone_044_temp', 'zone_044_fan_spd',\n",
|
556 |
+
" 'zone_043_temp', 'zone_043_fan_spd', 'zone_035_temp',\n",
|
557 |
+
" 'zone_035_fan_spd', 'zone_033_temp', 'zone_033_fan_spd',\n",
|
558 |
+
" 'zone_032_temp', 'zone_032_fan_spd', 'zone_030_temp',\n",
|
559 |
+
" 'zone_030_fan_spd', 'zone_028_temp', 'zone_028_fan_spd'],\n",
|
560 |
+
" dtype='object')"
|
561 |
+
]
|
562 |
+
},
|
563 |
+
"execution_count": 7,
|
564 |
+
"metadata": {},
|
565 |
+
"output_type": "execute_result"
|
566 |
+
}
|
567 |
+
],
|
568 |
+
"source": [
|
569 |
+
"traindataset_df.columns[0:31]"
|
570 |
+
]
|
571 |
+
},
|
572 |
+
{
|
573 |
+
"cell_type": "code",
|
574 |
+
"execution_count": 8,
|
575 |
+
"metadata": {},
|
576 |
+
"outputs": [
|
577 |
+
{
|
578 |
+
"name": "stdout",
|
579 |
+
"output_type": "stream",
|
580 |
+
"text": [
|
581 |
+
"0 0\n"
|
582 |
+
]
|
583 |
+
}
|
584 |
+
],
|
585 |
+
"source": [
|
586 |
+
"print(traindataset_df.isna().sum().sum(), testdataset_df.isna().sum().sum())"
|
587 |
+
]
|
588 |
+
},
|
589 |
+
{
|
590 |
+
"cell_type": "code",
|
591 |
+
"execution_count": 9,
|
592 |
+
"metadata": {},
|
593 |
+
"outputs": [
|
594 |
+
{
|
595 |
+
"data": {
|
596 |
+
"text/plain": [
|
597 |
+
"(1073512, 391818)"
|
598 |
+
]
|
599 |
+
},
|
600 |
+
"execution_count": 9,
|
601 |
+
"metadata": {},
|
602 |
+
"output_type": "execute_result"
|
603 |
+
}
|
604 |
+
],
|
605 |
+
"source": [
|
606 |
+
"len(traindataset), len(testdataset)"
|
607 |
+
]
|
608 |
+
},
|
609 |
+
{
|
610 |
+
"cell_type": "code",
|
611 |
+
"execution_count": 10,
|
612 |
+
"metadata": {},
|
613 |
+
"outputs": [],
|
614 |
+
"source": [
|
615 |
+
"traindataset = traindataset.astype('float32')\n",
|
616 |
+
"testdataset = testdataset.astype('float32')\n",
|
617 |
+
"\n",
|
618 |
+
"scaler = StandardScaler()\n",
|
619 |
+
"traindataset = scaler.fit_transform(traindataset)\n",
|
620 |
+
"testdataset = scaler.transform(testdataset)"
|
621 |
+
]
|
622 |
+
},
|
623 |
+
{
|
624 |
+
"cell_type": "code",
|
625 |
+
"execution_count": 11,
|
626 |
+
"metadata": {},
|
627 |
+
"outputs": [
|
628 |
+
{
|
629 |
+
"data": {
|
630 |
+
"text/plain": [
|
631 |
+
"(1073512, 55)"
|
632 |
+
]
|
633 |
+
},
|
634 |
+
"execution_count": 11,
|
635 |
+
"metadata": {},
|
636 |
+
"output_type": "execute_result"
|
637 |
+
}
|
638 |
+
],
|
639 |
+
"source": [
|
640 |
+
"traindataset.shape"
|
641 |
+
]
|
642 |
+
},
|
643 |
+
{
|
644 |
+
"cell_type": "code",
|
645 |
+
"execution_count": 12,
|
646 |
+
"metadata": {},
|
647 |
+
"outputs": [],
|
648 |
+
"source": [
|
649 |
+
"train,test = traindataset,testdataset\n",
|
650 |
+
"\n",
|
651 |
+
"def create_dataset(dataset,time_step):\n",
|
652 |
+
" x = []\n",
|
653 |
+
" Y = []\n",
|
654 |
+
" for i in range(len(dataset) - time_step - 1):\n",
|
655 |
+
" x.append(dataset[i:(i+time_step),:])\n",
|
656 |
+
" Y.append(dataset[i+time_step,0:31])\n",
|
657 |
+
" x= np.array(x)\n",
|
658 |
+
" Y = np.array(Y)\n",
|
659 |
+
" return x,Y\n",
|
660 |
+
"time_step = 30\n",
|
661 |
+
"X_train, y_train = create_dataset(train, time_step)\n",
|
662 |
+
"X_test, y_test = create_dataset(test, time_step)\n",
|
663 |
+
"\n"
|
664 |
+
]
|
665 |
+
},
|
666 |
+
{
|
667 |
+
"cell_type": "code",
|
668 |
+
"execution_count": 13,
|
669 |
+
"metadata": {},
|
670 |
+
"outputs": [
|
671 |
+
{
|
672 |
+
"data": {
|
673 |
+
"text/plain": [
|
674 |
+
"((1073481, 30, 55), (1073481, 31))"
|
675 |
+
]
|
676 |
+
},
|
677 |
+
"execution_count": 13,
|
678 |
+
"metadata": {},
|
679 |
+
"output_type": "execute_result"
|
680 |
+
}
|
681 |
+
],
|
682 |
+
"source": [
|
683 |
+
"X_train.shape, y_train.shape"
|
684 |
+
]
|
685 |
+
},
|
686 |
+
{
|
687 |
+
"cell_type": "code",
|
688 |
+
"execution_count": 14,
|
689 |
+
"metadata": {},
|
690 |
+
"outputs": [],
|
691 |
+
"source": [
|
692 |
+
"\n",
|
693 |
+
"model = Sequential()\n",
|
694 |
+
"model.add(LSTM(units=50, return_sequences=True, input_shape=(X_train.shape[1], X_train.shape[2])))\n",
|
695 |
+
"model.add(LSTM(units=50, return_sequences=True))\n",
|
696 |
+
"model.add(LSTM(units=30))\n",
|
697 |
+
"model.add(Dense(units=y_train.shape[1]))\n",
|
698 |
+
"\n",
|
699 |
+
"model.compile(optimizer='adam', loss='mean_squared_error')\n",
|
700 |
+
"\n",
|
701 |
+
"checkpoint_path = \"lstm_vav_02.tf\"\n",
|
702 |
+
"checkpoint_callback = ModelCheckpoint(filepath=checkpoint_path, monitor='val_loss', verbose=1, save_best_only=True, mode='min')\n",
|
703 |
+
"# model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=5, batch_size=128, verbose=1, callbacks=[checkpoint_callback])"
|
704 |
+
]
|
705 |
+
},
|
706 |
+
{
|
707 |
+
"cell_type": "code",
|
708 |
+
"execution_count": 15,
|
709 |
+
"metadata": {},
|
710 |
+
"outputs": [
|
711 |
+
{
|
712 |
+
"data": {
|
713 |
+
"text/plain": [
|
714 |
+
"<tensorflow.python.checkpoint.checkpoint.CheckpointLoadStatus at 0x2b142b76250>"
|
715 |
+
]
|
716 |
+
},
|
717 |
+
"execution_count": 15,
|
718 |
+
"metadata": {},
|
719 |
+
"output_type": "execute_result"
|
720 |
+
}
|
721 |
+
],
|
722 |
+
"source": [
|
723 |
+
"model.load_weights(checkpoint_path)"
|
724 |
+
]
|
725 |
+
},
|
726 |
+
{
|
727 |
+
"cell_type": "code",
|
728 |
+
"execution_count": 16,
|
729 |
+
"metadata": {},
|
730 |
+
"outputs": [
|
731 |
+
{
|
732 |
+
"name": "stdout",
|
733 |
+
"output_type": "stream",
|
734 |
+
"text": [
|
735 |
+
"12244/12244 [==============================] - 61s 5ms/step\n"
|
736 |
+
]
|
737 |
+
}
|
738 |
+
],
|
739 |
+
"source": [
|
740 |
+
"test_predict1 = model.predict(X_test)"
|
741 |
+
]
|
742 |
+
},
|
743 |
+
{
|
744 |
+
"cell_type": "code",
|
745 |
+
"execution_count": 19,
|
746 |
+
"metadata": {},
|
747 |
+
"outputs": [],
|
748 |
+
"source": [
|
749 |
+
"%matplotlib qt\n",
|
750 |
+
"plt.figure()\n",
|
751 |
+
"var = 2\n",
|
752 |
+
"plt.plot(y_test[:,var], label='Original Testing Data', color='blue')\n",
|
753 |
+
"plt.plot(test_predict1[:,var], label='Predicted Testing Data', color='red',alpha=0.8)\n",
|
754 |
+
"anomalies = np.where(abs(test_predict1[:,var] - y_test[:,var]) > 0.38)\n",
|
755 |
+
"plt.scatter(anomalies,test_predict1[anomalies,var], color='black',marker =\"o\",s=100 )\n",
|
756 |
+
"\n",
|
757 |
+
"\n",
|
758 |
+
"plt.title('Testing Data - Predicted vs Actual')\n",
|
759 |
+
"plt.xlabel('Time')\n",
|
760 |
+
"plt.ylabel('Value')\n",
|
761 |
+
"plt.legend()\n",
|
762 |
+
"plt.show()"
|
763 |
+
]
|
764 |
+
},
|
765 |
+
{
|
766 |
+
"cell_type": "code",
|
767 |
+
"execution_count": 18,
|
768 |
+
"metadata": {},
|
769 |
+
"outputs": [
|
770 |
+
{
|
771 |
+
"name": "stdout",
|
772 |
+
"output_type": "stream",
|
773 |
+
"text": [
|
774 |
+
" 1254/33547 [>.............................] - ETA: 3:00"
|
775 |
+
]
|
776 |
+
},
|
777 |
+
{
|
778 |
+
"ename": "KeyboardInterrupt",
|
779 |
+
"evalue": "",
|
780 |
+
"output_type": "error",
|
781 |
+
"traceback": [
|
782 |
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
783 |
+
"\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
|
784 |
+
"Cell \u001b[1;32mIn[18], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m get_ipython()\u001b[38;5;241m.\u001b[39mrun_line_magic(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmatplotlib\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mqt\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m----> 2\u001b[0m test_predict2 \u001b[38;5;241m=\u001b[39m \u001b[43mmodel\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpredict\u001b[49m\u001b[43m(\u001b[49m\u001b[43mX_train\u001b[49m\u001b[43m)\u001b[49m\n",
|
785 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\keras\\src\\utils\\traceback_utils.py:65\u001b[0m, in \u001b[0;36mfilter_traceback.<locals>.error_handler\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 63\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 64\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m---> 65\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 66\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 67\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m _process_traceback_frames(e\u001b[38;5;241m.\u001b[39m__traceback__)\n",
|
786 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\keras\\src\\engine\\training.py:2554\u001b[0m, in \u001b[0;36mModel.predict\u001b[1;34m(self, x, batch_size, verbose, steps, callbacks, max_queue_size, workers, use_multiprocessing)\u001b[0m\n\u001b[0;32m 2552\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m step \u001b[38;5;129;01min\u001b[39;00m data_handler\u001b[38;5;241m.\u001b[39msteps():\n\u001b[0;32m 2553\u001b[0m callbacks\u001b[38;5;241m.\u001b[39mon_predict_batch_begin(step)\n\u001b[1;32m-> 2554\u001b[0m tmp_batch_outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpredict_function\u001b[49m\u001b[43m(\u001b[49m\u001b[43miterator\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 2555\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m data_handler\u001b[38;5;241m.\u001b[39mshould_sync:\n\u001b[0;32m 2556\u001b[0m context\u001b[38;5;241m.\u001b[39masync_wait()\n",
|
787 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\util\\traceback_utils.py:150\u001b[0m, in \u001b[0;36mfilter_traceback.<locals>.error_handler\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 148\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 149\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 150\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 151\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 152\u001b[0m filtered_tb \u001b[38;5;241m=\u001b[39m _process_traceback_frames(e\u001b[38;5;241m.\u001b[39m__traceback__)\n",
|
788 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\polymorphic_function\\polymorphic_function.py:825\u001b[0m, in \u001b[0;36mFunction.__call__\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m 822\u001b[0m compiler \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mxla\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_jit_compile \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnonXla\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 824\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m OptionalXlaContext(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_jit_compile):\n\u001b[1;32m--> 825\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 827\u001b[0m new_tracing_count \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mexperimental_get_tracing_count()\n\u001b[0;32m 828\u001b[0m without_tracing \u001b[38;5;241m=\u001b[39m (tracing_count \u001b[38;5;241m==\u001b[39m new_tracing_count)\n",
|
789 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\polymorphic_function\\polymorphic_function.py:864\u001b[0m, in \u001b[0;36mFunction._call\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m 861\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_lock\u001b[38;5;241m.\u001b[39mrelease()\n\u001b[0;32m 862\u001b[0m \u001b[38;5;66;03m# In this case we have not created variables on the first call. So we can\u001b[39;00m\n\u001b[0;32m 863\u001b[0m \u001b[38;5;66;03m# run the first trace but we should fail if variables are created.\u001b[39;00m\n\u001b[1;32m--> 864\u001b[0m results \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_variable_creation_fn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 865\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_created_variables \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m ALLOW_DYNAMIC_VARIABLE_CREATION:\n\u001b[0;32m 866\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCreating variables on a non-first call to a function\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 867\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m decorated with tf.function.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
|
790 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\polymorphic_function\\tracing_compiler.py:148\u001b[0m, in \u001b[0;36mTracingCompiler.__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 145\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_lock:\n\u001b[0;32m 146\u001b[0m (concrete_function,\n\u001b[0;32m 147\u001b[0m filtered_flat_args) \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_maybe_define_function(args, kwargs)\n\u001b[1;32m--> 148\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mconcrete_function\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_flat\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 149\u001b[0m \u001b[43m \u001b[49m\u001b[43mfiltered_flat_args\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcaptured_inputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconcrete_function\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcaptured_inputs\u001b[49m\u001b[43m)\u001b[49m\n",
|
791 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\polymorphic_function\\monomorphic_function.py:1349\u001b[0m, in \u001b[0;36mConcreteFunction._call_flat\u001b[1;34m(self, args, captured_inputs)\u001b[0m\n\u001b[0;32m 1345\u001b[0m possible_gradient_type \u001b[38;5;241m=\u001b[39m gradients_util\u001b[38;5;241m.\u001b[39mPossibleTapeGradientTypes(args)\n\u001b[0;32m 1346\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (possible_gradient_type \u001b[38;5;241m==\u001b[39m gradients_util\u001b[38;5;241m.\u001b[39mPOSSIBLE_GRADIENT_TYPES_NONE\n\u001b[0;32m 1347\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m executing_eagerly):\n\u001b[0;32m 1348\u001b[0m \u001b[38;5;66;03m# No tape is watching; skip to running the function.\u001b[39;00m\n\u001b[1;32m-> 1349\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_build_call_outputs(\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_inference_function\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m)\u001b[49m)\n\u001b[0;32m 1350\u001b[0m forward_backward \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_select_forward_and_backward_functions(\n\u001b[0;32m 1351\u001b[0m args,\n\u001b[0;32m 1352\u001b[0m possible_gradient_type,\n\u001b[0;32m 1353\u001b[0m executing_eagerly)\n\u001b[0;32m 1354\u001b[0m forward_function, args_with_tangents \u001b[38;5;241m=\u001b[39m forward_backward\u001b[38;5;241m.\u001b[39mforward()\n",
|
792 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\polymorphic_function\\atomic_function.py:196\u001b[0m, in \u001b[0;36mAtomicFunction.__call__\u001b[1;34m(self, *args)\u001b[0m\n\u001b[0;32m 194\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m record\u001b[38;5;241m.\u001b[39mstop_recording():\n\u001b[0;32m 195\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_bound_context\u001b[38;5;241m.\u001b[39mexecuting_eagerly():\n\u001b[1;32m--> 196\u001b[0m outputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_bound_context\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcall_function\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 197\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 198\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mlist\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43margs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 199\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunction_type\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mflat_outputs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 200\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 201\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 202\u001b[0m outputs \u001b[38;5;241m=\u001b[39m make_call_op_in_graph(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;28mlist\u001b[39m(args))\n",
|
793 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\context.py:1457\u001b[0m, in \u001b[0;36mContext.call_function\u001b[1;34m(self, name, tensor_inputs, num_outputs)\u001b[0m\n\u001b[0;32m 1455\u001b[0m cancellation_context \u001b[38;5;241m=\u001b[39m cancellation\u001b[38;5;241m.\u001b[39mcontext()\n\u001b[0;32m 1456\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m cancellation_context \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m-> 1457\u001b[0m outputs \u001b[38;5;241m=\u001b[39m \u001b[43mexecute\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexecute\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 1458\u001b[0m \u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdecode\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mutf-8\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1459\u001b[0m \u001b[43m \u001b[49m\u001b[43mnum_outputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnum_outputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1460\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtensor_inputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1461\u001b[0m \u001b[43m \u001b[49m\u001b[43mattrs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mattrs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1462\u001b[0m \u001b[43m \u001b[49m\u001b[43mctx\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1463\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1464\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 1465\u001b[0m outputs \u001b[38;5;241m=\u001b[39m execute\u001b[38;5;241m.\u001b[39mexecute_with_cancellation(\n\u001b[0;32m 1466\u001b[0m name\u001b[38;5;241m.\u001b[39mdecode(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mutf-8\u001b[39m\u001b[38;5;124m\"\u001b[39m),\n\u001b[0;32m 1467\u001b[0m num_outputs\u001b[38;5;241m=\u001b[39mnum_outputs,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 1471\u001b[0m cancellation_manager\u001b[38;5;241m=\u001b[39mcancellation_context,\n\u001b[0;32m 1472\u001b[0m )\n",
|
794 |
+
"File \u001b[1;32md:\\Programs\\minconda3\\envs\\smartbuildings\\Lib\\site-packages\\tensorflow\\python\\eager\\execute.py:53\u001b[0m, in \u001b[0;36mquick_execute\u001b[1;34m(op_name, num_outputs, inputs, attrs, ctx, name)\u001b[0m\n\u001b[0;32m 51\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 52\u001b[0m ctx\u001b[38;5;241m.\u001b[39mensure_initialized()\n\u001b[1;32m---> 53\u001b[0m tensors \u001b[38;5;241m=\u001b[39m \u001b[43mpywrap_tfe\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mTFE_Py_Execute\u001b[49m\u001b[43m(\u001b[49m\u001b[43mctx\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_handle\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdevice_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mop_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 54\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mattrs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnum_outputs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 55\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m core\u001b[38;5;241m.\u001b[39m_NotOkStatusException \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 56\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m name \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
|
795 |
+
"\u001b[1;31mKeyboardInterrupt\u001b[0m: "
|
796 |
+
]
|
797 |
+
}
|
798 |
+
],
|
799 |
+
"source": [
|
800 |
+
"%matplotlib qt\n",
|
801 |
+
"test_predict2 = model.predict(X_train)\n",
|
802 |
+
"\n"
|
803 |
+
]
|
804 |
+
},
|
805 |
+
{
|
806 |
+
"cell_type": "code",
|
807 |
+
"execution_count": null,
|
808 |
+
"metadata": {},
|
809 |
+
"outputs": [],
|
810 |
+
"source": [
|
811 |
+
"plt.figure()\n",
|
812 |
+
"var = 3\n",
|
813 |
+
"plt.plot(y_train[:,var], label='Original Training Data', color='blue')\n",
|
814 |
+
"plt.plot(test_predict2[:,var], label='Predicted Training Data', color='red',alpha=0.8)\n",
|
815 |
+
"anomalies = np.where(abs(test_predict2[:,var] - y_train[:,var]) > 0.38)\n",
|
816 |
+
"plt.scatter(anomalies,test_predict2[anomalies,var], color='black',marker =\"o\",s=100 )\n",
|
817 |
+
"\n",
|
818 |
+
"\n",
|
819 |
+
"plt.title('Training Data - Predicted vs Actual')\n",
|
820 |
+
"plt.xlabel('Time')\n",
|
821 |
+
"plt.ylabel('Value')\n",
|
822 |
+
"plt.legend()\n",
|
823 |
+
"plt.show()"
|
824 |
+
]
|
825 |
+
},
|
826 |
+
{
|
827 |
+
"cell_type": "code",
|
828 |
+
"execution_count": null,
|
829 |
+
"metadata": {},
|
830 |
+
"outputs": [],
|
831 |
+
"source": [
|
832 |
+
"from sklearn.mixture import GaussianMixture\n",
|
833 |
+
"import numpy as np\n",
|
834 |
+
"import matplotlib.pyplot as plt\n",
|
835 |
+
"from sklearn.decomposition import PCA\n",
|
836 |
+
"\n",
|
837 |
+
"\n",
|
838 |
+
"# Generating random data for demonstration\n",
|
839 |
+
"np.random.seed(0)\n",
|
840 |
+
"X = test_predict1 - y_test\n",
|
841 |
+
"\n",
|
842 |
+
"\n",
|
843 |
+
"pca = PCA(n_components=2)\n",
|
844 |
+
"X = pca.fit_transform(X)\n",
|
845 |
+
"\n",
|
846 |
+
"\n",
|
847 |
+
"# Creating the GMM instance with desired number of clusters\n",
|
848 |
+
"gmm = GaussianMixture(n_components=2)\n",
|
849 |
+
"\n",
|
850 |
+
"# Fitting the model to the data\n",
|
851 |
+
"gmm.fit(X)\n",
|
852 |
+
"\n",
|
853 |
+
"# Getting the cluster labels\n",
|
854 |
+
"labels = gmm.predict(X)\n",
|
855 |
+
"\n",
|
856 |
+
"# Plotting the data points with colors representing different clusters\n",
|
857 |
+
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
858 |
+
"plt.title('GMM Clustering')\n",
|
859 |
+
"plt.xlabel('Feature 1')\n",
|
860 |
+
"plt.ylabel('Feature 2')\n",
|
861 |
+
"plt.show()\n"
|
862 |
+
]
|
863 |
+
},
|
864 |
+
{
|
865 |
+
"cell_type": "code",
|
866 |
+
"execution_count": 22,
|
867 |
+
"metadata": {},
|
868 |
+
"outputs": [],
|
869 |
+
"source": [
|
870 |
+
"from sklearn.cluster import KMeans\n",
|
871 |
+
"import numpy as np\n",
|
872 |
+
"import matplotlib.pyplot as plt\n",
|
873 |
+
"from sklearn.decomposition import PCA\n",
|
874 |
+
"\n",
|
875 |
+
"# Generating random data for demonstration\n",
|
876 |
+
"np.random.seed(0)\n",
|
877 |
+
"X = (test_predict1 - y_test)\n",
|
878 |
+
"\n",
|
879 |
+
"k = 6\n",
|
880 |
+
"\n",
|
881 |
+
"kmeans = KMeans(n_clusters=k)\n",
|
882 |
+
"\n",
|
883 |
+
"kmeans.fit(X)\n",
|
884 |
+
"\n",
|
885 |
+
"pca = PCA(n_components=2)\n",
|
886 |
+
"X = pca.fit_transform(X)\n",
|
887 |
+
"\n",
|
888 |
+
"\n",
|
889 |
+
"\n",
|
890 |
+
"# Getting the cluster centers and labels\n",
|
891 |
+
"centroids = kmeans.cluster_centers_\n",
|
892 |
+
"centroids = pca.transform(centroids)\n",
|
893 |
+
"labels = kmeans.labels_\n",
|
894 |
+
"\n",
|
895 |
+
"# Plotting the data points and cluster centers\n",
|
896 |
+
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
897 |
+
"plt.scatter(centroids[:, 0], centroids[:, 1], marker='x', c='red', s=200, linewidths=2)\n",
|
898 |
+
"plt.title('KMeans Clustering')\n",
|
899 |
+
"plt.xlabel('Feature 1')\n",
|
900 |
+
"plt.ylabel('Feature 2')\n",
|
901 |
+
"plt.show()\n"
|
902 |
+
]
|
903 |
+
},
|
904 |
+
{
|
905 |
+
"cell_type": "code",
|
906 |
+
"execution_count": 20,
|
907 |
+
"metadata": {},
|
908 |
+
"outputs": [],
|
909 |
+
"source": [
|
910 |
+
"k = 60\n",
|
911 |
+
"X= test_predict1 - y_test\n",
|
912 |
+
"processed_data = []\n",
|
913 |
+
"feat_df = pd.DataFrame(columns=[\"mean\",\"std\",])\n",
|
914 |
+
"for i in range(0,len(X), 60):\n",
|
915 |
+
" mean = X[i:i+k].mean(axis = 0)\n",
|
916 |
+
" std = X[i:i+k].std(axis = 0)\n",
|
917 |
+
" max = X[i:i+k].max(axis = 0)\n",
|
918 |
+
" min = X[i:i+k].min(axis = 0)\n",
|
919 |
+
" iqr = np.percentile(X[i:i+k], 75, axis=0) - np.percentile(X[i:i+k], 25,axis=0)\n",
|
920 |
+
" data = np.concatenate([mean, std, max, min, iqr])\n",
|
921 |
+
" processed_data.append([data])\n",
|
922 |
+
"processed_data = np.concatenate(processed_data,axis=0) "
|
923 |
+
]
|
924 |
+
},
|
925 |
+
{
|
926 |
+
"cell_type": "code",
|
927 |
+
"execution_count": 23,
|
928 |
+
"metadata": {},
|
929 |
+
"outputs": [],
|
930 |
+
"source": [
|
931 |
+
"X = processed_data\n",
|
932 |
+
"\n",
|
933 |
+
"kmeans = KMeans(n_clusters=2, algorithm='elkan', max_iter=1000, n_init = 5)\n",
|
934 |
+
"\n",
|
935 |
+
"kmeans.fit(X)\n",
|
936 |
+
"\n",
|
937 |
+
"pca = PCA(n_components=2)\n",
|
938 |
+
"X = pca.fit_transform(X)\n",
|
939 |
+
"\n",
|
940 |
+
"\n",
|
941 |
+
"# Getting the cluster centers and labels\n",
|
942 |
+
"centroids = kmeans.cluster_centers_\n",
|
943 |
+
"centroids = pca.transform(centroids)\n",
|
944 |
+
"labels = kmeans.labels_\n",
|
945 |
+
"\n",
|
946 |
+
"# Plotting the data points and cluster centers\n",
|
947 |
+
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
948 |
+
"plt.scatter(centroids[:, 0], centroids[:, 1], marker='x', c='red', s=200, linewidths=2)\n",
|
949 |
+
"plt.title('KMeans Clustering')\n",
|
950 |
+
"plt.xlabel('Feature 1')\n",
|
951 |
+
"plt.ylabel('Feature 2')\n",
|
952 |
+
"plt.show()\n"
|
953 |
+
]
|
954 |
+
},
|
955 |
+
{
|
956 |
+
"cell_type": "code",
|
957 |
+
"execution_count": null,
|
958 |
+
"metadata": {},
|
959 |
+
"outputs": [],
|
960 |
+
"source": [
|
961 |
+
"from sklearn.mixture import GaussianMixture\n",
|
962 |
+
"import numpy as np\n",
|
963 |
+
"import matplotlib.pyplot as plt\n",
|
964 |
+
"from sklearn.decomposition import PCA\n",
|
965 |
+
"\n",
|
966 |
+
"# Generating random data for demonstration\n",
|
967 |
+
"np.random.seed(0)\n",
|
968 |
+
"X = processed_data\n",
|
969 |
+
"\n",
|
970 |
+
"# Creating the GMM instance with desired number of clusters\n",
|
971 |
+
"gmm = GaussianMixture(n_components=2, init_params='k-means++')\n",
|
972 |
+
"\n",
|
973 |
+
"# Fitting the model to the data\n",
|
974 |
+
"gmm.fit(X)\n",
|
975 |
+
"labels = gmm.predict(X)\n",
|
976 |
+
"\n",
|
977 |
+
"\n",
|
978 |
+
"pca = PCA(n_components=2)\n",
|
979 |
+
"X = pca.fit_transform(X)\n",
|
980 |
+
"\n",
|
981 |
+
"\n",
|
982 |
+
"# Getting the cluster labels\n",
|
983 |
+
"\n",
|
984 |
+
"# Plotting the data points with colors representing different clusters\n",
|
985 |
+
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
986 |
+
"plt.title('GMM Clustering')\n",
|
987 |
+
"plt.xlabel('Feature 1')\n",
|
988 |
+
"plt.ylabel('Feature 2')\n",
|
989 |
+
"plt.show()\n",
|
990 |
+
"\n"
|
991 |
+
]
|
992 |
+
},
|
993 |
+
{
|
994 |
+
"cell_type": "code",
|
995 |
+
"execution_count": null,
|
996 |
+
"metadata": {},
|
997 |
+
"outputs": [],
|
998 |
+
"source": [
|
999 |
+
"from sklearn.cluster import KMeans\n",
|
1000 |
+
"import numpy as np\n",
|
1001 |
+
"import matplotlib.pyplot as plt\n",
|
1002 |
+
"# Generating random data for demonstration\n",
|
1003 |
+
"np.random.seed(0)\n",
|
1004 |
+
"X = test_predict1 - y_test \n",
|
1005 |
+
"\n",
|
1006 |
+
"kmeans = KMeans(n_clusters=2)\n",
|
1007 |
+
"\n",
|
1008 |
+
"kmeans.fit(X)\n",
|
1009 |
+
"\n",
|
1010 |
+
"\n",
|
1011 |
+
"pca = PCA(n_components=2)\n",
|
1012 |
+
"X = pca.fit_transform(X)\n",
|
1013 |
+
"\n",
|
1014 |
+
"\n",
|
1015 |
+
"\n",
|
1016 |
+
"# Getting the cluster centers and labels\n",
|
1017 |
+
"centroids = kmeans.cluster_centers_\n",
|
1018 |
+
"centroids = pca.transform(centroids)\n",
|
1019 |
+
"labels = kmeans.labels_\n",
|
1020 |
+
"\n",
|
1021 |
+
"# Plotting the data points and cluster centers\n",
|
1022 |
+
"plt.figure()\n",
|
1023 |
+
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
1024 |
+
"plt.scatter(centroids[:, 0], centroids[:, 1], marker='x', c='red', s=200, linewidths=2)\n",
|
1025 |
+
"plt.text(centroids[0,0], centroids[0,1], 'Normal', fontsize=12, color='red')\n",
|
1026 |
+
"plt.text(centroids[1,0], centroids[1,1], 'Anomaly', fontsize=12, color='red')\n",
|
1027 |
+
"plt.title('KMeans Clustering')\n",
|
1028 |
+
"plt.xlabel('Feature 1')\n",
|
1029 |
+
"plt.ylabel('Feature 2')\n",
|
1030 |
+
"plt.show()\n"
|
1031 |
+
]
|
1032 |
+
},
|
1033 |
+
{
|
1034 |
+
"cell_type": "code",
|
1035 |
+
"execution_count": null,
|
1036 |
+
"metadata": {},
|
1037 |
+
"outputs": [
|
1038 |
+
{
|
1039 |
+
"data": {
|
1040 |
+
"text/plain": [
|
1041 |
+
"329763"
|
1042 |
+
]
|
1043 |
+
},
|
1044 |
+
"execution_count": 26,
|
1045 |
+
"metadata": {},
|
1046 |
+
"output_type": "execute_result"
|
1047 |
+
}
|
1048 |
+
],
|
1049 |
+
"source": [
|
1050 |
+
"sum(labels==0)"
|
1051 |
+
]
|
1052 |
+
}
|
1053 |
+
],
|
1054 |
+
"metadata": {
|
1055 |
+
"kernelspec": {
|
1056 |
+
"display_name": "tensorflow",
|
1057 |
+
"language": "python",
|
1058 |
+
"name": "python3"
|
1059 |
+
},
|
1060 |
+
"language_info": {
|
1061 |
+
"codemirror_mode": {
|
1062 |
+
"name": "ipython",
|
1063 |
+
"version": 3
|
1064 |
+
},
|
1065 |
+
"file_extension": ".py",
|
1066 |
+
"mimetype": "text/x-python",
|
1067 |
+
"name": "python",
|
1068 |
+
"nbconvert_exporter": "python",
|
1069 |
+
"pygments_lexer": "ipython3",
|
1070 |
+
"version": "3.11.8"
|
1071 |
+
}
|
1072 |
+
},
|
1073 |
+
"nbformat": 4,
|
1074 |
+
"nbformat_minor": 2
|
1075 |
+
}
|
physLSTM/lstm_vav_rtu3.ipynb
ADDED
@@ -0,0 +1,1131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import pandas as pd \n",
|
10 |
+
"from datetime import datetime \n",
|
11 |
+
"from datetime import date\n",
|
12 |
+
"import matplotlib.pyplot as plt\n",
|
13 |
+
"import numpy as np\n",
|
14 |
+
"import pandas as pd\n",
|
15 |
+
"from keras.models import Sequential\n",
|
16 |
+
"from keras.layers import LSTM, Dense\n",
|
17 |
+
"from sklearn.model_selection import train_test_split\n",
|
18 |
+
"from sklearn.preprocessing import MinMaxScaler,StandardScaler\n",
|
19 |
+
"from keras.callbacks import ModelCheckpoint\n",
|
20 |
+
"import tensorflow as tf"
|
21 |
+
]
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"cell_type": "code",
|
25 |
+
"execution_count": 2,
|
26 |
+
"metadata": {},
|
27 |
+
"outputs": [],
|
28 |
+
"source": [
|
29 |
+
"merged = pd.read_csv(r'../data/long_merge.csv')"
|
30 |
+
]
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"cell_type": "code",
|
34 |
+
"execution_count": 7,
|
35 |
+
"metadata": {},
|
36 |
+
"outputs": [],
|
37 |
+
"source": [
|
38 |
+
"zones = [72, 71, 63, 62, 60, 59, 58,57, 50, 49, 44, 43, 35, 34, 33, 32, 31, 30, 29, 28, ]\n",
|
39 |
+
"rtus = [2]\n",
|
40 |
+
"cols = []\n",
|
41 |
+
"\n",
|
42 |
+
"for zone in zones:\n",
|
43 |
+
" for column in merged.columns:\n",
|
44 |
+
" if f\"zone_0{zone}\" in column and 'co2' not in column and \"hw_valve\" not in column and \"cooling_sp\" not in column and \"heating_sp\" not in column:\n",
|
45 |
+
" cols.append(column)\n",
|
46 |
+
"\n",
|
47 |
+
"for zone in zones:\n",
|
48 |
+
" for column in merged.columns:\n",
|
49 |
+
" if f\"zone_0{zone}\" in column: \n",
|
50 |
+
" if \"cooling_sp\" in column or \"heating_sp\" in column:\n",
|
51 |
+
" cols.append(column)\n",
|
52 |
+
"# for rtu in rtus:\n",
|
53 |
+
"# for column in merged.columns:\n",
|
54 |
+
"# if f\"rtu_00{rtu}_fltrd_sa\" in column:\n",
|
55 |
+
"# cols.append(column)\n",
|
56 |
+
"cols =['date'] + cols + ['air_temp_set_1',\n",
|
57 |
+
" 'air_temp_set_2',\n",
|
58 |
+
" 'dew_point_temperature_set_1d',\n",
|
59 |
+
" 'relative_humidity_set_1',\n",
|
60 |
+
" 'solar_radiation_set_1']\n",
|
61 |
+
"input_dataset = merged[cols]"
|
62 |
+
]
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"cell_type": "code",
|
66 |
+
"execution_count": 11,
|
67 |
+
"metadata": {},
|
68 |
+
"outputs": [
|
69 |
+
{
|
70 |
+
"name": "stderr",
|
71 |
+
"output_type": "stream",
|
72 |
+
"text": [
|
73 |
+
"C:\\Users\\arbal\\AppData\\Local\\Temp\\ipykernel_34660\\1855433847.py:1: SettingWithCopyWarning: \n",
|
74 |
+
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
75 |
+
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
76 |
+
"\n",
|
77 |
+
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
78 |
+
" input_dataset['date'] = pd.to_datetime(input_dataset['date'], format = \"%Y-%m-%d %H:%M:%S\")\n"
|
79 |
+
]
|
80 |
+
}
|
81 |
+
],
|
82 |
+
"source": [
|
83 |
+
"input_dataset['date'] = pd.to_datetime(input_dataset['date'], format = \"%Y-%m-%d %H:%M:%S\")\n",
|
84 |
+
"df_filtered = input_dataset[ (input_dataset.date.dt.date >date(2019, 3, 1)) & (input_dataset.date.dt.date< date(2021, 1, 1))]\n",
|
85 |
+
"\n",
|
86 |
+
"if df_filtered.isna().any().any():\n",
|
87 |
+
" print(\"There are NA values in the DataFrame columns.\")"
|
88 |
+
]
|
89 |
+
},
|
90 |
+
{
|
91 |
+
"cell_type": "code",
|
92 |
+
"execution_count": 12,
|
93 |
+
"metadata": {},
|
94 |
+
"outputs": [
|
95 |
+
{
|
96 |
+
"data": {
|
97 |
+
"text/html": [
|
98 |
+
"<div>\n",
|
99 |
+
"<style scoped>\n",
|
100 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
101 |
+
" vertical-align: middle;\n",
|
102 |
+
" }\n",
|
103 |
+
"\n",
|
104 |
+
" .dataframe tbody tr th {\n",
|
105 |
+
" vertical-align: top;\n",
|
106 |
+
" }\n",
|
107 |
+
"\n",
|
108 |
+
" .dataframe thead th {\n",
|
109 |
+
" text-align: right;\n",
|
110 |
+
" }\n",
|
111 |
+
"</style>\n",
|
112 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
113 |
+
" <thead>\n",
|
114 |
+
" <tr style=\"text-align: right;\">\n",
|
115 |
+
" <th></th>\n",
|
116 |
+
" <th>date</th>\n",
|
117 |
+
" <th>zone_072_temp</th>\n",
|
118 |
+
" <th>zone_072_fan_spd</th>\n",
|
119 |
+
" <th>zone_071_temp</th>\n",
|
120 |
+
" <th>zone_071_fan_spd</th>\n",
|
121 |
+
" <th>zone_063_temp</th>\n",
|
122 |
+
" <th>zone_063_fan_spd</th>\n",
|
123 |
+
" <th>zone_062_temp</th>\n",
|
124 |
+
" <th>zone_062_fan_spd</th>\n",
|
125 |
+
" <th>zone_059_temp</th>\n",
|
126 |
+
" <th>...</th>\n",
|
127 |
+
" <th>zone_035_heating_sp</th>\n",
|
128 |
+
" <th>zone_032_cooling_sp</th>\n",
|
129 |
+
" <th>zone_032_heating_sp</th>\n",
|
130 |
+
" <th>zone_030_cooling_sp</th>\n",
|
131 |
+
" <th>zone_030_heating_sp</th>\n",
|
132 |
+
" <th>air_temp_set_1</th>\n",
|
133 |
+
" <th>air_temp_set_2</th>\n",
|
134 |
+
" <th>dew_point_temperature_set_1d</th>\n",
|
135 |
+
" <th>relative_humidity_set_1</th>\n",
|
136 |
+
" <th>solar_radiation_set_1</th>\n",
|
137 |
+
" </tr>\n",
|
138 |
+
" </thead>\n",
|
139 |
+
" <tbody>\n",
|
140 |
+
" <tr>\n",
|
141 |
+
" <th>511205</th>\n",
|
142 |
+
" <td>2019-03-02 00:00:00</td>\n",
|
143 |
+
" <td>71.2</td>\n",
|
144 |
+
" <td>40.0</td>\n",
|
145 |
+
" <td>71.5</td>\n",
|
146 |
+
" <td>20.0</td>\n",
|
147 |
+
" <td>72.3</td>\n",
|
148 |
+
" <td>20.0</td>\n",
|
149 |
+
" <td>72.9</td>\n",
|
150 |
+
" <td>55.0</td>\n",
|
151 |
+
" <td>71.9</td>\n",
|
152 |
+
" <td>...</td>\n",
|
153 |
+
" <td>70.0</td>\n",
|
154 |
+
" <td>74.000000</td>\n",
|
155 |
+
" <td>68.0</td>\n",
|
156 |
+
" <td>73.0</td>\n",
|
157 |
+
" <td>67.0</td>\n",
|
158 |
+
" <td>11.590</td>\n",
|
159 |
+
" <td>11.130</td>\n",
|
160 |
+
" <td>3.00</td>\n",
|
161 |
+
" <td>55.87</td>\n",
|
162 |
+
" <td>120.3</td>\n",
|
163 |
+
" </tr>\n",
|
164 |
+
" <tr>\n",
|
165 |
+
" <th>511206</th>\n",
|
166 |
+
" <td>2019-03-02 00:01:00</td>\n",
|
167 |
+
" <td>71.2</td>\n",
|
168 |
+
" <td>40.0</td>\n",
|
169 |
+
" <td>71.5</td>\n",
|
170 |
+
" <td>20.0</td>\n",
|
171 |
+
" <td>72.3</td>\n",
|
172 |
+
" <td>20.0</td>\n",
|
173 |
+
" <td>72.9</td>\n",
|
174 |
+
" <td>55.0</td>\n",
|
175 |
+
" <td>71.9</td>\n",
|
176 |
+
" <td>...</td>\n",
|
177 |
+
" <td>70.0</td>\n",
|
178 |
+
" <td>74.000000</td>\n",
|
179 |
+
" <td>68.0</td>\n",
|
180 |
+
" <td>73.0</td>\n",
|
181 |
+
" <td>67.0</td>\n",
|
182 |
+
" <td>11.590</td>\n",
|
183 |
+
" <td>11.130</td>\n",
|
184 |
+
" <td>3.00</td>\n",
|
185 |
+
" <td>55.87</td>\n",
|
186 |
+
" <td>120.3</td>\n",
|
187 |
+
" </tr>\n",
|
188 |
+
" <tr>\n",
|
189 |
+
" <th>511207</th>\n",
|
190 |
+
" <td>2019-03-02 00:02:00</td>\n",
|
191 |
+
" <td>71.2</td>\n",
|
192 |
+
" <td>40.0</td>\n",
|
193 |
+
" <td>71.5</td>\n",
|
194 |
+
" <td>20.0</td>\n",
|
195 |
+
" <td>72.3</td>\n",
|
196 |
+
" <td>20.0</td>\n",
|
197 |
+
" <td>72.6</td>\n",
|
198 |
+
" <td>55.0</td>\n",
|
199 |
+
" <td>71.9</td>\n",
|
200 |
+
" <td>...</td>\n",
|
201 |
+
" <td>70.0</td>\n",
|
202 |
+
" <td>74.000000</td>\n",
|
203 |
+
" <td>68.0</td>\n",
|
204 |
+
" <td>73.0</td>\n",
|
205 |
+
" <td>67.0</td>\n",
|
206 |
+
" <td>11.590</td>\n",
|
207 |
+
" <td>11.130</td>\n",
|
208 |
+
" <td>3.00</td>\n",
|
209 |
+
" <td>55.87</td>\n",
|
210 |
+
" <td>120.3</td>\n",
|
211 |
+
" </tr>\n",
|
212 |
+
" <tr>\n",
|
213 |
+
" <th>511208</th>\n",
|
214 |
+
" <td>2019-03-02 00:03:00</td>\n",
|
215 |
+
" <td>71.2</td>\n",
|
216 |
+
" <td>40.0</td>\n",
|
217 |
+
" <td>71.5</td>\n",
|
218 |
+
" <td>20.0</td>\n",
|
219 |
+
" <td>72.3</td>\n",
|
220 |
+
" <td>20.0</td>\n",
|
221 |
+
" <td>72.9</td>\n",
|
222 |
+
" <td>55.0</td>\n",
|
223 |
+
" <td>71.9</td>\n",
|
224 |
+
" <td>...</td>\n",
|
225 |
+
" <td>70.0</td>\n",
|
226 |
+
" <td>74.000000</td>\n",
|
227 |
+
" <td>68.0</td>\n",
|
228 |
+
" <td>73.0</td>\n",
|
229 |
+
" <td>67.0</td>\n",
|
230 |
+
" <td>11.590</td>\n",
|
231 |
+
" <td>11.130</td>\n",
|
232 |
+
" <td>3.00</td>\n",
|
233 |
+
" <td>55.87</td>\n",
|
234 |
+
" <td>120.3</td>\n",
|
235 |
+
" </tr>\n",
|
236 |
+
" <tr>\n",
|
237 |
+
" <th>511209</th>\n",
|
238 |
+
" <td>2019-03-02 00:04:00</td>\n",
|
239 |
+
" <td>71.2</td>\n",
|
240 |
+
" <td>40.0</td>\n",
|
241 |
+
" <td>71.4</td>\n",
|
242 |
+
" <td>20.0</td>\n",
|
243 |
+
" <td>72.3</td>\n",
|
244 |
+
" <td>20.0</td>\n",
|
245 |
+
" <td>72.9</td>\n",
|
246 |
+
" <td>55.0</td>\n",
|
247 |
+
" <td>71.9</td>\n",
|
248 |
+
" <td>...</td>\n",
|
249 |
+
" <td>70.0</td>\n",
|
250 |
+
" <td>74.000000</td>\n",
|
251 |
+
" <td>68.0</td>\n",
|
252 |
+
" <td>73.0</td>\n",
|
253 |
+
" <td>67.0</td>\n",
|
254 |
+
" <td>11.590</td>\n",
|
255 |
+
" <td>11.130</td>\n",
|
256 |
+
" <td>3.00</td>\n",
|
257 |
+
" <td>55.87</td>\n",
|
258 |
+
" <td>120.3</td>\n",
|
259 |
+
" </tr>\n",
|
260 |
+
" <tr>\n",
|
261 |
+
" <th>...</th>\n",
|
262 |
+
" <td>...</td>\n",
|
263 |
+
" <td>...</td>\n",
|
264 |
+
" <td>...</td>\n",
|
265 |
+
" <td>...</td>\n",
|
266 |
+
" <td>...</td>\n",
|
267 |
+
" <td>...</td>\n",
|
268 |
+
" <td>...</td>\n",
|
269 |
+
" <td>...</td>\n",
|
270 |
+
" <td>...</td>\n",
|
271 |
+
" <td>...</td>\n",
|
272 |
+
" <td>...</td>\n",
|
273 |
+
" <td>...</td>\n",
|
274 |
+
" <td>...</td>\n",
|
275 |
+
" <td>...</td>\n",
|
276 |
+
" <td>...</td>\n",
|
277 |
+
" <td>...</td>\n",
|
278 |
+
" <td>...</td>\n",
|
279 |
+
" <td>...</td>\n",
|
280 |
+
" <td>...</td>\n",
|
281 |
+
" <td>...</td>\n",
|
282 |
+
" <td>...</td>\n",
|
283 |
+
" </tr>\n",
|
284 |
+
" <tr>\n",
|
285 |
+
" <th>2072148</th>\n",
|
286 |
+
" <td>2020-12-31 23:57:00</td>\n",
|
287 |
+
" <td>69.5</td>\n",
|
288 |
+
" <td>40.0</td>\n",
|
289 |
+
" <td>71.2</td>\n",
|
290 |
+
" <td>20.0</td>\n",
|
291 |
+
" <td>68.0</td>\n",
|
292 |
+
" <td>20.0</td>\n",
|
293 |
+
" <td>67.6</td>\n",
|
294 |
+
" <td>40.0</td>\n",
|
295 |
+
" <td>67.5</td>\n",
|
296 |
+
" <td>...</td>\n",
|
297 |
+
" <td>68.0</td>\n",
|
298 |
+
" <td>72.714138</td>\n",
|
299 |
+
" <td>71.0</td>\n",
|
300 |
+
" <td>71.0</td>\n",
|
301 |
+
" <td>70.0</td>\n",
|
302 |
+
" <td>13.994</td>\n",
|
303 |
+
" <td>13.528</td>\n",
|
304 |
+
" <td>4.11</td>\n",
|
305 |
+
" <td>51.61</td>\n",
|
306 |
+
" <td>188.8</td>\n",
|
307 |
+
" </tr>\n",
|
308 |
+
" <tr>\n",
|
309 |
+
" <th>2072149</th>\n",
|
310 |
+
" <td>2020-12-31 23:58:00</td>\n",
|
311 |
+
" <td>69.5</td>\n",
|
312 |
+
" <td>40.0</td>\n",
|
313 |
+
" <td>71.3</td>\n",
|
314 |
+
" <td>20.0</td>\n",
|
315 |
+
" <td>68.0</td>\n",
|
316 |
+
" <td>20.0</td>\n",
|
317 |
+
" <td>67.6</td>\n",
|
318 |
+
" <td>40.0</td>\n",
|
319 |
+
" <td>67.5</td>\n",
|
320 |
+
" <td>...</td>\n",
|
321 |
+
" <td>68.0</td>\n",
|
322 |
+
" <td>72.714138</td>\n",
|
323 |
+
" <td>71.0</td>\n",
|
324 |
+
" <td>71.0</td>\n",
|
325 |
+
" <td>70.0</td>\n",
|
326 |
+
" <td>13.994</td>\n",
|
327 |
+
" <td>13.528</td>\n",
|
328 |
+
" <td>4.11</td>\n",
|
329 |
+
" <td>51.61</td>\n",
|
330 |
+
" <td>188.8</td>\n",
|
331 |
+
" </tr>\n",
|
332 |
+
" <tr>\n",
|
333 |
+
" <th>2072150</th>\n",
|
334 |
+
" <td>2020-12-31 23:58:00</td>\n",
|
335 |
+
" <td>69.5</td>\n",
|
336 |
+
" <td>40.0</td>\n",
|
337 |
+
" <td>71.3</td>\n",
|
338 |
+
" <td>20.0</td>\n",
|
339 |
+
" <td>68.0</td>\n",
|
340 |
+
" <td>20.0</td>\n",
|
341 |
+
" <td>67.6</td>\n",
|
342 |
+
" <td>40.0</td>\n",
|
343 |
+
" <td>67.5</td>\n",
|
344 |
+
" <td>...</td>\n",
|
345 |
+
" <td>68.0</td>\n",
|
346 |
+
" <td>72.714138</td>\n",
|
347 |
+
" <td>71.0</td>\n",
|
348 |
+
" <td>71.0</td>\n",
|
349 |
+
" <td>70.0</td>\n",
|
350 |
+
" <td>13.994</td>\n",
|
351 |
+
" <td>13.528</td>\n",
|
352 |
+
" <td>4.11</td>\n",
|
353 |
+
" <td>51.61</td>\n",
|
354 |
+
" <td>188.8</td>\n",
|
355 |
+
" </tr>\n",
|
356 |
+
" <tr>\n",
|
357 |
+
" <th>2072151</th>\n",
|
358 |
+
" <td>2020-12-31 23:59:00</td>\n",
|
359 |
+
" <td>69.5</td>\n",
|
360 |
+
" <td>40.0</td>\n",
|
361 |
+
" <td>71.5</td>\n",
|
362 |
+
" <td>20.0</td>\n",
|
363 |
+
" <td>68.0</td>\n",
|
364 |
+
" <td>20.0</td>\n",
|
365 |
+
" <td>67.6</td>\n",
|
366 |
+
" <td>40.0</td>\n",
|
367 |
+
" <td>67.5</td>\n",
|
368 |
+
" <td>...</td>\n",
|
369 |
+
" <td>68.0</td>\n",
|
370 |
+
" <td>72.714138</td>\n",
|
371 |
+
" <td>71.0</td>\n",
|
372 |
+
" <td>71.0</td>\n",
|
373 |
+
" <td>70.0</td>\n",
|
374 |
+
" <td>13.994</td>\n",
|
375 |
+
" <td>13.528</td>\n",
|
376 |
+
" <td>4.11</td>\n",
|
377 |
+
" <td>51.61</td>\n",
|
378 |
+
" <td>188.8</td>\n",
|
379 |
+
" </tr>\n",
|
380 |
+
" <tr>\n",
|
381 |
+
" <th>2072152</th>\n",
|
382 |
+
" <td>2020-12-31 23:59:00</td>\n",
|
383 |
+
" <td>69.5</td>\n",
|
384 |
+
" <td>40.0</td>\n",
|
385 |
+
" <td>71.5</td>\n",
|
386 |
+
" <td>20.0</td>\n",
|
387 |
+
" <td>68.0</td>\n",
|
388 |
+
" <td>20.0</td>\n",
|
389 |
+
" <td>67.6</td>\n",
|
390 |
+
" <td>40.0</td>\n",
|
391 |
+
" <td>67.5</td>\n",
|
392 |
+
" <td>...</td>\n",
|
393 |
+
" <td>68.0</td>\n",
|
394 |
+
" <td>72.714138</td>\n",
|
395 |
+
" <td>71.0</td>\n",
|
396 |
+
" <td>71.0</td>\n",
|
397 |
+
" <td>70.0</td>\n",
|
398 |
+
" <td>13.994</td>\n",
|
399 |
+
" <td>13.528</td>\n",
|
400 |
+
" <td>4.11</td>\n",
|
401 |
+
" <td>51.61</td>\n",
|
402 |
+
" <td>188.8</td>\n",
|
403 |
+
" </tr>\n",
|
404 |
+
" </tbody>\n",
|
405 |
+
"</table>\n",
|
406 |
+
"<p>1560948 rows × 56 columns</p>\n",
|
407 |
+
"</div>"
|
408 |
+
],
|
409 |
+
"text/plain": [
|
410 |
+
" date zone_072_temp zone_072_fan_spd zone_071_temp \\\n",
|
411 |
+
"511205 2019-03-02 00:00:00 71.2 40.0 71.5 \n",
|
412 |
+
"511206 2019-03-02 00:01:00 71.2 40.0 71.5 \n",
|
413 |
+
"511207 2019-03-02 00:02:00 71.2 40.0 71.5 \n",
|
414 |
+
"511208 2019-03-02 00:03:00 71.2 40.0 71.5 \n",
|
415 |
+
"511209 2019-03-02 00:04:00 71.2 40.0 71.4 \n",
|
416 |
+
"... ... ... ... ... \n",
|
417 |
+
"2072148 2020-12-31 23:57:00 69.5 40.0 71.2 \n",
|
418 |
+
"2072149 2020-12-31 23:58:00 69.5 40.0 71.3 \n",
|
419 |
+
"2072150 2020-12-31 23:58:00 69.5 40.0 71.3 \n",
|
420 |
+
"2072151 2020-12-31 23:59:00 69.5 40.0 71.5 \n",
|
421 |
+
"2072152 2020-12-31 23:59:00 69.5 40.0 71.5 \n",
|
422 |
+
"\n",
|
423 |
+
" zone_071_fan_spd zone_063_temp zone_063_fan_spd zone_062_temp \\\n",
|
424 |
+
"511205 20.0 72.3 20.0 72.9 \n",
|
425 |
+
"511206 20.0 72.3 20.0 72.9 \n",
|
426 |
+
"511207 20.0 72.3 20.0 72.6 \n",
|
427 |
+
"511208 20.0 72.3 20.0 72.9 \n",
|
428 |
+
"511209 20.0 72.3 20.0 72.9 \n",
|
429 |
+
"... ... ... ... ... \n",
|
430 |
+
"2072148 20.0 68.0 20.0 67.6 \n",
|
431 |
+
"2072149 20.0 68.0 20.0 67.6 \n",
|
432 |
+
"2072150 20.0 68.0 20.0 67.6 \n",
|
433 |
+
"2072151 20.0 68.0 20.0 67.6 \n",
|
434 |
+
"2072152 20.0 68.0 20.0 67.6 \n",
|
435 |
+
"\n",
|
436 |
+
" zone_062_fan_spd zone_059_temp ... zone_035_heating_sp \\\n",
|
437 |
+
"511205 55.0 71.9 ... 70.0 \n",
|
438 |
+
"511206 55.0 71.9 ... 70.0 \n",
|
439 |
+
"511207 55.0 71.9 ... 70.0 \n",
|
440 |
+
"511208 55.0 71.9 ... 70.0 \n",
|
441 |
+
"511209 55.0 71.9 ... 70.0 \n",
|
442 |
+
"... ... ... ... ... \n",
|
443 |
+
"2072148 40.0 67.5 ... 68.0 \n",
|
444 |
+
"2072149 40.0 67.5 ... 68.0 \n",
|
445 |
+
"2072150 40.0 67.5 ... 68.0 \n",
|
446 |
+
"2072151 40.0 67.5 ... 68.0 \n",
|
447 |
+
"2072152 40.0 67.5 ... 68.0 \n",
|
448 |
+
"\n",
|
449 |
+
" zone_032_cooling_sp zone_032_heating_sp zone_030_cooling_sp \\\n",
|
450 |
+
"511205 74.000000 68.0 73.0 \n",
|
451 |
+
"511206 74.000000 68.0 73.0 \n",
|
452 |
+
"511207 74.000000 68.0 73.0 \n",
|
453 |
+
"511208 74.000000 68.0 73.0 \n",
|
454 |
+
"511209 74.000000 68.0 73.0 \n",
|
455 |
+
"... ... ... ... \n",
|
456 |
+
"2072148 72.714138 71.0 71.0 \n",
|
457 |
+
"2072149 72.714138 71.0 71.0 \n",
|
458 |
+
"2072150 72.714138 71.0 71.0 \n",
|
459 |
+
"2072151 72.714138 71.0 71.0 \n",
|
460 |
+
"2072152 72.714138 71.0 71.0 \n",
|
461 |
+
"\n",
|
462 |
+
" zone_030_heating_sp air_temp_set_1 air_temp_set_2 \\\n",
|
463 |
+
"511205 67.0 11.590 11.130 \n",
|
464 |
+
"511206 67.0 11.590 11.130 \n",
|
465 |
+
"511207 67.0 11.590 11.130 \n",
|
466 |
+
"511208 67.0 11.590 11.130 \n",
|
467 |
+
"511209 67.0 11.590 11.130 \n",
|
468 |
+
"... ... ... ... \n",
|
469 |
+
"2072148 70.0 13.994 13.528 \n",
|
470 |
+
"2072149 70.0 13.994 13.528 \n",
|
471 |
+
"2072150 70.0 13.994 13.528 \n",
|
472 |
+
"2072151 70.0 13.994 13.528 \n",
|
473 |
+
"2072152 70.0 13.994 13.528 \n",
|
474 |
+
"\n",
|
475 |
+
" dew_point_temperature_set_1d relative_humidity_set_1 \\\n",
|
476 |
+
"511205 3.00 55.87 \n",
|
477 |
+
"511206 3.00 55.87 \n",
|
478 |
+
"511207 3.00 55.87 \n",
|
479 |
+
"511208 3.00 55.87 \n",
|
480 |
+
"511209 3.00 55.87 \n",
|
481 |
+
"... ... ... \n",
|
482 |
+
"2072148 4.11 51.61 \n",
|
483 |
+
"2072149 4.11 51.61 \n",
|
484 |
+
"2072150 4.11 51.61 \n",
|
485 |
+
"2072151 4.11 51.61 \n",
|
486 |
+
"2072152 4.11 51.61 \n",
|
487 |
+
"\n",
|
488 |
+
" solar_radiation_set_1 \n",
|
489 |
+
"511205 120.3 \n",
|
490 |
+
"511206 120.3 \n",
|
491 |
+
"511207 120.3 \n",
|
492 |
+
"511208 120.3 \n",
|
493 |
+
"511209 120.3 \n",
|
494 |
+
"... ... \n",
|
495 |
+
"2072148 188.8 \n",
|
496 |
+
"2072149 188.8 \n",
|
497 |
+
"2072150 188.8 \n",
|
498 |
+
"2072151 188.8 \n",
|
499 |
+
"2072152 188.8 \n",
|
500 |
+
"\n",
|
501 |
+
"[1560948 rows x 56 columns]"
|
502 |
+
]
|
503 |
+
},
|
504 |
+
"execution_count": 12,
|
505 |
+
"metadata": {},
|
506 |
+
"output_type": "execute_result"
|
507 |
+
}
|
508 |
+
],
|
509 |
+
"source": [
|
510 |
+
"df_filtered"
|
511 |
+
]
|
512 |
+
},
|
513 |
+
{
|
514 |
+
"cell_type": "code",
|
515 |
+
"execution_count": 13,
|
516 |
+
"metadata": {},
|
517 |
+
"outputs": [
|
518 |
+
{
|
519 |
+
"data": {
|
520 |
+
"text/plain": [
|
521 |
+
"[]"
|
522 |
+
]
|
523 |
+
},
|
524 |
+
"execution_count": 13,
|
525 |
+
"metadata": {},
|
526 |
+
"output_type": "execute_result"
|
527 |
+
}
|
528 |
+
],
|
529 |
+
"source": [
|
530 |
+
"testdataset_df = df_filtered[(df_filtered.date.dt.date >date(2020, 3, 1)) & (df_filtered.date.dt.date <date(2020,7, 1))]\n",
|
531 |
+
"\n",
|
532 |
+
"# traindataset_df = df_filtered[ (df_filtered.date.dt.date >date(2019, 11, 8))]\n",
|
533 |
+
"\n",
|
534 |
+
"traindataset_df = df_filtered[(df_filtered.date.dt.date >date(2019, 3, 1)) & (df_filtered.date.dt.date <date(2020, 3, 1)) | (df_filtered.date.dt.date >date(2020, 7, 1)) & (df_filtered.date.dt.date <date(2020, 12, 1))]\n",
|
535 |
+
"testdataset = testdataset_df.drop(columns=[\"date\"]).values\n",
|
536 |
+
"traindataset = traindataset_df.drop(columns=[\"date\"]).values\n",
|
537 |
+
"\n",
|
538 |
+
"columns_with_na = traindataset_df.columns[traindataset_df.isna().any()].tolist()\n",
|
539 |
+
"columns_with_na"
|
540 |
+
]
|
541 |
+
},
|
542 |
+
{
|
543 |
+
"cell_type": "code",
|
544 |
+
"execution_count": 20,
|
545 |
+
"metadata": {},
|
546 |
+
"outputs": [
|
547 |
+
{
|
548 |
+
"data": {
|
549 |
+
"text/plain": [
|
550 |
+
"Index(['date', 'zone_072_temp', 'zone_072_fan_spd', 'zone_071_temp',\n",
|
551 |
+
" 'zone_071_fan_spd', 'zone_063_temp', 'zone_063_fan_spd',\n",
|
552 |
+
" 'zone_062_temp', 'zone_062_fan_spd', 'zone_059_temp',\n",
|
553 |
+
" 'zone_059_fan_spd', 'zone_058_temp', 'zone_058_fan_spd',\n",
|
554 |
+
" 'zone_057_temp', 'zone_057_fan_spd', 'zone_049_temp',\n",
|
555 |
+
" 'zone_049_fan_spd', 'zone_044_temp', 'zone_044_fan_spd',\n",
|
556 |
+
" 'zone_043_temp', 'zone_043_fan_spd', 'zone_035_temp',\n",
|
557 |
+
" 'zone_035_fan_spd', 'zone_033_temp', 'zone_033_fan_spd',\n",
|
558 |
+
" 'zone_032_temp', 'zone_032_fan_spd', 'zone_030_temp',\n",
|
559 |
+
" 'zone_030_fan_spd', 'zone_028_temp', 'zone_028_fan_spd'],\n",
|
560 |
+
" dtype='object')"
|
561 |
+
]
|
562 |
+
},
|
563 |
+
"execution_count": 20,
|
564 |
+
"metadata": {},
|
565 |
+
"output_type": "execute_result"
|
566 |
+
}
|
567 |
+
],
|
568 |
+
"source": [
|
569 |
+
"traindataset_df.columns[0:31]"
|
570 |
+
]
|
571 |
+
},
|
572 |
+
{
|
573 |
+
"cell_type": "code",
|
574 |
+
"execution_count": 14,
|
575 |
+
"metadata": {},
|
576 |
+
"outputs": [
|
577 |
+
{
|
578 |
+
"name": "stdout",
|
579 |
+
"output_type": "stream",
|
580 |
+
"text": [
|
581 |
+
"0 0\n"
|
582 |
+
]
|
583 |
+
}
|
584 |
+
],
|
585 |
+
"source": [
|
586 |
+
"print(traindataset_df.isna().sum().sum(), testdataset_df.isna().sum().sum())"
|
587 |
+
]
|
588 |
+
},
|
589 |
+
{
|
590 |
+
"cell_type": "code",
|
591 |
+
"execution_count": 15,
|
592 |
+
"metadata": {},
|
593 |
+
"outputs": [
|
594 |
+
{
|
595 |
+
"data": {
|
596 |
+
"text/plain": [
|
597 |
+
"(1073512, 391818)"
|
598 |
+
]
|
599 |
+
},
|
600 |
+
"execution_count": 15,
|
601 |
+
"metadata": {},
|
602 |
+
"output_type": "execute_result"
|
603 |
+
}
|
604 |
+
],
|
605 |
+
"source": [
|
606 |
+
"len(traindataset), len(testdataset)"
|
607 |
+
]
|
608 |
+
},
|
609 |
+
{
|
610 |
+
"cell_type": "code",
|
611 |
+
"execution_count": 16,
|
612 |
+
"metadata": {},
|
613 |
+
"outputs": [],
|
614 |
+
"source": [
|
615 |
+
"traindataset = traindataset.astype('float32')\n",
|
616 |
+
"testdataset = testdataset.astype('float32')\n",
|
617 |
+
"\n",
|
618 |
+
"scaler = StandardScaler()\n",
|
619 |
+
"traindataset = scaler.fit_transform(traindataset)\n",
|
620 |
+
"testdataset = scaler.transform(testdataset)"
|
621 |
+
]
|
622 |
+
},
|
623 |
+
{
|
624 |
+
"cell_type": "code",
|
625 |
+
"execution_count": 17,
|
626 |
+
"metadata": {},
|
627 |
+
"outputs": [
|
628 |
+
{
|
629 |
+
"data": {
|
630 |
+
"text/plain": [
|
631 |
+
"(1073512, 55)"
|
632 |
+
]
|
633 |
+
},
|
634 |
+
"execution_count": 17,
|
635 |
+
"metadata": {},
|
636 |
+
"output_type": "execute_result"
|
637 |
+
}
|
638 |
+
],
|
639 |
+
"source": [
|
640 |
+
"traindataset.shape"
|
641 |
+
]
|
642 |
+
},
|
643 |
+
{
|
644 |
+
"cell_type": "code",
|
645 |
+
"execution_count": 21,
|
646 |
+
"metadata": {},
|
647 |
+
"outputs": [],
|
648 |
+
"source": [
|
649 |
+
"train,test = traindataset,testdataset\n",
|
650 |
+
"\n",
|
651 |
+
"def create_dataset(dataset,time_step):\n",
|
652 |
+
" x = []\n",
|
653 |
+
" Y = []\n",
|
654 |
+
" for i in range(len(dataset) - time_step - 1):\n",
|
655 |
+
" x.append(dataset[i:(i+time_step),:])\n",
|
656 |
+
" Y.append(dataset[i+time_step,0:31])\n",
|
657 |
+
" x= np.array(x)\n",
|
658 |
+
" Y = np.array(Y)\n",
|
659 |
+
" return x,Y\n",
|
660 |
+
"time_step = 30\n",
|
661 |
+
"X_train, y_train = create_dataset(train, time_step)\n",
|
662 |
+
"X_test, y_test = create_dataset(test, time_step)\n",
|
663 |
+
"\n"
|
664 |
+
]
|
665 |
+
},
|
666 |
+
{
|
667 |
+
"cell_type": "code",
|
668 |
+
"execution_count": 22,
|
669 |
+
"metadata": {},
|
670 |
+
"outputs": [
|
671 |
+
{
|
672 |
+
"data": {
|
673 |
+
"text/plain": [
|
674 |
+
"((1073481, 30, 55), (1073481, 31))"
|
675 |
+
]
|
676 |
+
},
|
677 |
+
"execution_count": 22,
|
678 |
+
"metadata": {},
|
679 |
+
"output_type": "execute_result"
|
680 |
+
}
|
681 |
+
],
|
682 |
+
"source": [
|
683 |
+
"X_train.shape, y_train.shape"
|
684 |
+
]
|
685 |
+
},
|
686 |
+
{
|
687 |
+
"cell_type": "code",
|
688 |
+
"execution_count": 24,
|
689 |
+
"metadata": {},
|
690 |
+
"outputs": [
|
691 |
+
{
|
692 |
+
"name": "stdout",
|
693 |
+
"output_type": "stream",
|
694 |
+
"text": [
|
695 |
+
"Epoch 1/5\n",
|
696 |
+
"8386/8387 [============================>.] - ETA: 0s - loss: 0.0512\n",
|
697 |
+
"Epoch 1: val_loss improved from inf to 0.29908, saving model to lstm_vav_02.tf\n",
|
698 |
+
"INFO:tensorflow:Assets written to: lstm_vav_02.tf\\assets\n"
|
699 |
+
]
|
700 |
+
},
|
701 |
+
{
|
702 |
+
"name": "stderr",
|
703 |
+
"output_type": "stream",
|
704 |
+
"text": [
|
705 |
+
"INFO:tensorflow:Assets written to: lstm_vav_02.tf\\assets\n"
|
706 |
+
]
|
707 |
+
},
|
708 |
+
{
|
709 |
+
"name": "stdout",
|
710 |
+
"output_type": "stream",
|
711 |
+
"text": [
|
712 |
+
"8387/8387 [==============================] - 337s 40ms/step - loss: 0.0512 - val_loss: 0.2991\n",
|
713 |
+
"Epoch 2/5\n",
|
714 |
+
"8387/8387 [==============================] - ETA: 0s - loss: 0.0213\n",
|
715 |
+
"Epoch 2: val_loss improved from 0.29908 to 0.23285, saving model to lstm_vav_02.tf\n",
|
716 |
+
"INFO:tensorflow:Assets written to: lstm_vav_02.tf\\assets\n"
|
717 |
+
]
|
718 |
+
},
|
719 |
+
{
|
720 |
+
"name": "stderr",
|
721 |
+
"output_type": "stream",
|
722 |
+
"text": [
|
723 |
+
"INFO:tensorflow:Assets written to: lstm_vav_02.tf\\assets\n"
|
724 |
+
]
|
725 |
+
},
|
726 |
+
{
|
727 |
+
"name": "stdout",
|
728 |
+
"output_type": "stream",
|
729 |
+
"text": [
|
730 |
+
"8387/8387 [==============================] - 300s 36ms/step - loss: 0.0213 - val_loss: 0.2328\n",
|
731 |
+
"Epoch 3/5\n",
|
732 |
+
"8387/8387 [==============================] - ETA: 0s - loss: 0.0152\n",
|
733 |
+
"Epoch 3: val_loss did not improve from 0.23285\n",
|
734 |
+
"8387/8387 [==============================] - 359s 43ms/step - loss: 0.0152 - val_loss: 0.2426\n",
|
735 |
+
"Epoch 4/5\n",
|
736 |
+
"8387/8387 [==============================] - ETA: 0s - loss: 0.0106\n",
|
737 |
+
"Epoch 4: val_loss did not improve from 0.23285\n",
|
738 |
+
"8387/8387 [==============================] - 350s 42ms/step - loss: 0.0106 - val_loss: 0.2556\n",
|
739 |
+
"Epoch 5/5\n",
|
740 |
+
"8386/8387 [============================>.] - ETA: 0s - loss: 0.0096\n",
|
741 |
+
"Epoch 5: val_loss did not improve from 0.23285\n",
|
742 |
+
"8387/8387 [==============================] - 349s 42ms/step - loss: 0.0096 - val_loss: 0.2635\n"
|
743 |
+
]
|
744 |
+
},
|
745 |
+
{
|
746 |
+
"data": {
|
747 |
+
"text/plain": [
|
748 |
+
"<keras.src.callbacks.History at 0x27dbd115490>"
|
749 |
+
]
|
750 |
+
},
|
751 |
+
"execution_count": 24,
|
752 |
+
"metadata": {},
|
753 |
+
"output_type": "execute_result"
|
754 |
+
}
|
755 |
+
],
|
756 |
+
"source": [
|
757 |
+
"\n",
|
758 |
+
"model = Sequential()\n",
|
759 |
+
"model.add(LSTM(units=50, return_sequences=True, input_shape=(X_train.shape[1], X_train.shape[2])))\n",
|
760 |
+
"model.add(LSTM(units=50, return_sequences=True))\n",
|
761 |
+
"model.add(LSTM(units=30))\n",
|
762 |
+
"model.add(Dense(units=y_train.shape[1]))\n",
|
763 |
+
"\n",
|
764 |
+
"model.compile(optimizer='adam', loss='mean_squared_error')\n",
|
765 |
+
"\n",
|
766 |
+
"checkpoint_path = \"lstm_vav_02.tf\"\n",
|
767 |
+
"checkpoint_callback = ModelCheckpoint(filepath=checkpoint_path, monitor='val_loss', verbose=1, save_best_only=True, mode='min')\n",
|
768 |
+
"model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=5, batch_size=128, verbose=1, callbacks=[checkpoint_callback])"
|
769 |
+
]
|
770 |
+
},
|
771 |
+
{
|
772 |
+
"cell_type": "code",
|
773 |
+
"execution_count": 14,
|
774 |
+
"metadata": {},
|
775 |
+
"outputs": [
|
776 |
+
{
|
777 |
+
"data": {
|
778 |
+
"text/plain": [
|
779 |
+
"<tensorflow.python.checkpoint.checkpoint.CheckpointLoadStatus at 0x2a4b2344610>"
|
780 |
+
]
|
781 |
+
},
|
782 |
+
"execution_count": 14,
|
783 |
+
"metadata": {},
|
784 |
+
"output_type": "execute_result"
|
785 |
+
}
|
786 |
+
],
|
787 |
+
"source": [
|
788 |
+
"model.load_weights(checkpoint_path)"
|
789 |
+
]
|
790 |
+
},
|
791 |
+
{
|
792 |
+
"cell_type": "code",
|
793 |
+
"execution_count": 25,
|
794 |
+
"metadata": {},
|
795 |
+
"outputs": [
|
796 |
+
{
|
797 |
+
"name": "stdout",
|
798 |
+
"output_type": "stream",
|
799 |
+
"text": [
|
800 |
+
"12244/12244 [==============================] - 60s 5ms/step\n"
|
801 |
+
]
|
802 |
+
}
|
803 |
+
],
|
804 |
+
"source": [
|
805 |
+
"test_predict1 = model.predict(X_test)"
|
806 |
+
]
|
807 |
+
},
|
808 |
+
{
|
809 |
+
"cell_type": "code",
|
810 |
+
"execution_count": 35,
|
811 |
+
"metadata": {},
|
812 |
+
"outputs": [],
|
813 |
+
"source": [
|
814 |
+
"%matplotlib qt\n",
|
815 |
+
"plt.figure()\n",
|
816 |
+
"var = 1\n",
|
817 |
+
"plt.plot(y_test[:,var], label='Original Testing Data', color='blue')\n",
|
818 |
+
"plt.plot(test_predict1[:,var], label='Predicted Testing Data', color='red',alpha=0.8)\n",
|
819 |
+
"anomalies = np.where(abs(test_predict1[:,var] - y_test[:,var]) > 0.38)\n",
|
820 |
+
"plt.scatter(anomalies,test_predict1[anomalies,var], color='black',marker =\"o\",s=100 )\n",
|
821 |
+
"\n",
|
822 |
+
"\n",
|
823 |
+
"plt.title('Testing Data - Predicted vs Actual')\n",
|
824 |
+
"plt.xlabel('Time')\n",
|
825 |
+
"plt.ylabel('Value')\n",
|
826 |
+
"plt.legend()\n",
|
827 |
+
"plt.show()"
|
828 |
+
]
|
829 |
+
},
|
830 |
+
{
|
831 |
+
"cell_type": "code",
|
832 |
+
"execution_count": 36,
|
833 |
+
"metadata": {},
|
834 |
+
"outputs": [
|
835 |
+
{
|
836 |
+
"name": "stdout",
|
837 |
+
"output_type": "stream",
|
838 |
+
"text": [
|
839 |
+
"33547/33547 [==============================] - 201s 6ms/step\n"
|
840 |
+
]
|
841 |
+
},
|
842 |
+
{
|
843 |
+
"ename": "ValueError",
|
844 |
+
"evalue": "operands could not be broadcast together with shapes (1073481,) (391787,) ",
|
845 |
+
"output_type": "error",
|
846 |
+
"traceback": [
|
847 |
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
848 |
+
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
|
849 |
+
"Cell \u001b[1;32mIn[36], line 8\u001b[0m\n\u001b[0;32m 6\u001b[0m plt\u001b[38;5;241m.\u001b[39mplot(y_train[:,var], label\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mOriginal Testing Data\u001b[39m\u001b[38;5;124m'\u001b[39m, color\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mblue\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m 7\u001b[0m plt\u001b[38;5;241m.\u001b[39mplot(test_predict2[:,var], label\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mPredicted Testing Data\u001b[39m\u001b[38;5;124m'\u001b[39m, color\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mred\u001b[39m\u001b[38;5;124m'\u001b[39m,alpha\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m0.8\u001b[39m)\n\u001b[1;32m----> 8\u001b[0m anomalies \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mwhere(\u001b[38;5;28mabs\u001b[39m(\u001b[43mtest_predict2\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[43m,\u001b[49m\u001b[43mvar\u001b[49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[43m \u001b[49m\u001b[43my_test\u001b[49m\u001b[43m[\u001b[49m\u001b[43m:\u001b[49m\u001b[43m,\u001b[49m\u001b[43mvar\u001b[49m\u001b[43m]\u001b[49m) \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m0.38\u001b[39m)\n\u001b[0;32m 9\u001b[0m plt\u001b[38;5;241m.\u001b[39mscatter(anomalies,test_predict2[anomalies,var], color\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mblack\u001b[39m\u001b[38;5;124m'\u001b[39m,marker \u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mo\u001b[39m\u001b[38;5;124m\"\u001b[39m,s\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m100\u001b[39m )\n\u001b[0;32m 12\u001b[0m plt\u001b[38;5;241m.\u001b[39mtitle(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mTraining Data - Predicted vs Actual\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
|
850 |
+
"\u001b[1;31mValueError\u001b[0m: operands could not be broadcast together with shapes (1073481,) (391787,) "
|
851 |
+
]
|
852 |
+
}
|
853 |
+
],
|
854 |
+
"source": [
|
855 |
+
"%matplotlib qt\n",
|
856 |
+
"test_predict2 = model.predict(X_train)\n",
|
857 |
+
"\n"
|
858 |
+
]
|
859 |
+
},
|
860 |
+
{
|
861 |
+
"cell_type": "code",
|
862 |
+
"execution_count": 39,
|
863 |
+
"metadata": {},
|
864 |
+
"outputs": [],
|
865 |
+
"source": [
|
866 |
+
"plt.figure()\n",
|
867 |
+
"var = 3\n",
|
868 |
+
"plt.plot(y_train[:,var], label='Original Training Data', color='blue')\n",
|
869 |
+
"plt.plot(test_predict2[:,var], label='Predicted Training Data', color='red',alpha=0.8)\n",
|
870 |
+
"anomalies = np.where(abs(test_predict2[:,var] - y_train[:,var]) > 0.38)\n",
|
871 |
+
"plt.scatter(anomalies,test_predict2[anomalies,var], color='black',marker =\"o\",s=100 )\n",
|
872 |
+
"\n",
|
873 |
+
"\n",
|
874 |
+
"plt.title('Training Data - Predicted vs Actual')\n",
|
875 |
+
"plt.xlabel('Time')\n",
|
876 |
+
"plt.ylabel('Value')\n",
|
877 |
+
"plt.legend()\n",
|
878 |
+
"plt.show()"
|
879 |
+
]
|
880 |
+
},
|
881 |
+
{
|
882 |
+
"cell_type": "code",
|
883 |
+
"execution_count": 29,
|
884 |
+
"metadata": {},
|
885 |
+
"outputs": [],
|
886 |
+
"source": [
|
887 |
+
"from sklearn.mixture import GaussianMixture\n",
|
888 |
+
"import numpy as np\n",
|
889 |
+
"import matplotlib.pyplot as plt\n",
|
890 |
+
"from sklearn.decomposition import PCA\n",
|
891 |
+
"\n",
|
892 |
+
"\n",
|
893 |
+
"# Generating random data for demonstration\n",
|
894 |
+
"np.random.seed(0)\n",
|
895 |
+
"X = test_predict1 - y_test\n",
|
896 |
+
"\n",
|
897 |
+
"\n",
|
898 |
+
"pca = PCA(n_components=2)\n",
|
899 |
+
"X = pca.fit_transform(X)\n",
|
900 |
+
"\n",
|
901 |
+
"\n",
|
902 |
+
"# Creating the GMM instance with desired number of clusters\n",
|
903 |
+
"gmm = GaussianMixture(n_components=2)\n",
|
904 |
+
"\n",
|
905 |
+
"# Fitting the model to the data\n",
|
906 |
+
"gmm.fit(X)\n",
|
907 |
+
"\n",
|
908 |
+
"# Getting the cluster labels\n",
|
909 |
+
"labels = gmm.predict(X)\n",
|
910 |
+
"\n",
|
911 |
+
"# Plotting the data points with colors representing different clusters\n",
|
912 |
+
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
913 |
+
"plt.title('GMM Clustering')\n",
|
914 |
+
"plt.xlabel('Feature 1')\n",
|
915 |
+
"plt.ylabel('Feature 2')\n",
|
916 |
+
"plt.show()\n"
|
917 |
+
]
|
918 |
+
},
|
919 |
+
{
|
920 |
+
"cell_type": "code",
|
921 |
+
"execution_count": 30,
|
922 |
+
"metadata": {},
|
923 |
+
"outputs": [],
|
924 |
+
"source": [
|
925 |
+
"from sklearn.cluster import KMeans\n",
|
926 |
+
"import numpy as np\n",
|
927 |
+
"import matplotlib.pyplot as plt\n",
|
928 |
+
"from sklearn.decomposition import PCA\n",
|
929 |
+
"\n",
|
930 |
+
"# Generating random data for demonstration\n",
|
931 |
+
"np.random.seed(0)\n",
|
932 |
+
"X = (test_predict1 - y_test)\n",
|
933 |
+
"\n",
|
934 |
+
"k = 6\n",
|
935 |
+
"\n",
|
936 |
+
"kmeans = KMeans(n_clusters=k)\n",
|
937 |
+
"\n",
|
938 |
+
"kmeans.fit(X)\n",
|
939 |
+
"\n",
|
940 |
+
"\n",
|
941 |
+
"pca = PCA(n_components=2)\n",
|
942 |
+
"X = pca.fit_transform(X)\n",
|
943 |
+
"\n",
|
944 |
+
"\n",
|
945 |
+
"\n",
|
946 |
+
"# Getting the cluster centers and labels\n",
|
947 |
+
"centroids = kmeans.cluster_centers_\n",
|
948 |
+
"centroids = pca.transform(centroids)\n",
|
949 |
+
"labels = kmeans.labels_\n",
|
950 |
+
"\n",
|
951 |
+
"# Plotting the data points and cluster centers\n",
|
952 |
+
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
953 |
+
"plt.scatter(centroids[:, 0], centroids[:, 1], marker='x', c='red', s=200, linewidths=2)\n",
|
954 |
+
"plt.title('KMeans Clustering')\n",
|
955 |
+
"plt.xlabel('Feature 1')\n",
|
956 |
+
"plt.ylabel('Feature 2')\n",
|
957 |
+
"plt.show()\n"
|
958 |
+
]
|
959 |
+
},
|
960 |
+
{
|
961 |
+
"cell_type": "code",
|
962 |
+
"execution_count": 32,
|
963 |
+
"metadata": {},
|
964 |
+
"outputs": [],
|
965 |
+
"source": [
|
966 |
+
"k = 60\n",
|
967 |
+
"X= test_predict1 - y_test\n",
|
968 |
+
"processed_data = []\n",
|
969 |
+
"feat_df = pd.DataFrame(columns=[\"mean\",\"std\",])\n",
|
970 |
+
"for i in range(0,len(X), 60):\n",
|
971 |
+
" mean = X[i:i+k].mean(axis = 0)\n",
|
972 |
+
" std = X[i:i+k].std(axis = 0)\n",
|
973 |
+
" max = X[i:i+k].max(axis = 0)\n",
|
974 |
+
" min = X[i:i+k].min(axis = 0)\n",
|
975 |
+
" iqr = np.percentile(X[i:i+k], 75, axis=0) - np.percentile(X[i:i+k], 25,axis=0)\n",
|
976 |
+
" data = np.concatenate([mean, std, max, min, iqr])\n",
|
977 |
+
" processed_data.append([data])\n",
|
978 |
+
"processed_data = np.concatenate(processed_data,axis=0) "
|
979 |
+
]
|
980 |
+
},
|
981 |
+
{
|
982 |
+
"cell_type": "code",
|
983 |
+
"execution_count": 34,
|
984 |
+
"metadata": {},
|
985 |
+
"outputs": [],
|
986 |
+
"source": [
|
987 |
+
"X = processed_data\n",
|
988 |
+
"\n",
|
989 |
+
"kmeans = KMeans(n_clusters=2, algorithm='elkan', max_iter=1000, n_init = 5)\n",
|
990 |
+
"\n",
|
991 |
+
"kmeans.fit(X)\n",
|
992 |
+
"\n",
|
993 |
+
"pca = PCA(n_components=2)\n",
|
994 |
+
"X = pca.fit_transform(X)\n",
|
995 |
+
"\n",
|
996 |
+
"\n",
|
997 |
+
"# Getting the cluster centers and labels\n",
|
998 |
+
"centroids = kmeans.cluster_centers_\n",
|
999 |
+
"centroids = pca.transform(centroids)\n",
|
1000 |
+
"labels = kmeans.labels_\n",
|
1001 |
+
"\n",
|
1002 |
+
"# Plotting the data points and cluster centers\n",
|
1003 |
+
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
1004 |
+
"plt.scatter(centroids[:, 0], centroids[:, 1], marker='x', c='red', s=200, linewidths=2)\n",
|
1005 |
+
"plt.title('KMeans Clustering')\n",
|
1006 |
+
"plt.xlabel('Feature 1')\n",
|
1007 |
+
"plt.ylabel('Feature 2')\n",
|
1008 |
+
"plt.show()\n"
|
1009 |
+
]
|
1010 |
+
},
|
1011 |
+
{
|
1012 |
+
"cell_type": "code",
|
1013 |
+
"execution_count": 21,
|
1014 |
+
"metadata": {},
|
1015 |
+
"outputs": [],
|
1016 |
+
"source": [
|
1017 |
+
"from sklearn.mixture import GaussianMixture\n",
|
1018 |
+
"import numpy as np\n",
|
1019 |
+
"import matplotlib.pyplot as plt\n",
|
1020 |
+
"from sklearn.decomposition import PCA\n",
|
1021 |
+
"\n",
|
1022 |
+
"# Generating random data for demonstration\n",
|
1023 |
+
"np.random.seed(0)\n",
|
1024 |
+
"X = processed_data\n",
|
1025 |
+
"\n",
|
1026 |
+
"# Creating the GMM instance with desired number of clusters\n",
|
1027 |
+
"gmm = GaussianMixture(n_components=2, init_params='k-means++')\n",
|
1028 |
+
"\n",
|
1029 |
+
"# Fitting the model to the data\n",
|
1030 |
+
"gmm.fit(X)\n",
|
1031 |
+
"labels = gmm.predict(X)\n",
|
1032 |
+
"\n",
|
1033 |
+
"\n",
|
1034 |
+
"pca = PCA(n_components=2)\n",
|
1035 |
+
"X = pca.fit_transform(X)\n",
|
1036 |
+
"\n",
|
1037 |
+
"\n",
|
1038 |
+
"# Getting the cluster labels\n",
|
1039 |
+
"\n",
|
1040 |
+
"# Plotting the data points with colors representing different clusters\n",
|
1041 |
+
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
1042 |
+
"plt.title('GMM Clustering')\n",
|
1043 |
+
"plt.xlabel('Feature 1')\n",
|
1044 |
+
"plt.ylabel('Feature 2')\n",
|
1045 |
+
"plt.show()\n",
|
1046 |
+
"\n"
|
1047 |
+
]
|
1048 |
+
},
|
1049 |
+
{
|
1050 |
+
"cell_type": "code",
|
1051 |
+
"execution_count": 38,
|
1052 |
+
"metadata": {},
|
1053 |
+
"outputs": [],
|
1054 |
+
"source": [
|
1055 |
+
"from sklearn.cluster import KMeans\n",
|
1056 |
+
"import numpy as np\n",
|
1057 |
+
"import matplotlib.pyplot as plt\n",
|
1058 |
+
"# Generating random data for demonstration\n",
|
1059 |
+
"np.random.seed(0)\n",
|
1060 |
+
"X = test_predict1 - y_test \n",
|
1061 |
+
"\n",
|
1062 |
+
"kmeans = KMeans(n_clusters=2)\n",
|
1063 |
+
"\n",
|
1064 |
+
"kmeans.fit(X)\n",
|
1065 |
+
"\n",
|
1066 |
+
"\n",
|
1067 |
+
"pca = PCA(n_components=2)\n",
|
1068 |
+
"X = pca.fit_transform(X)\n",
|
1069 |
+
"\n",
|
1070 |
+
"\n",
|
1071 |
+
"\n",
|
1072 |
+
"# Getting the cluster centers and labels\n",
|
1073 |
+
"centroids = kmeans.cluster_centers_\n",
|
1074 |
+
"centroids = pca.transform(centroids)\n",
|
1075 |
+
"labels = kmeans.labels_\n",
|
1076 |
+
"\n",
|
1077 |
+
"# Plotting the data points and cluster centers\n",
|
1078 |
+
"plt.figure()\n",
|
1079 |
+
"plt.scatter(X[:, 0], X[:, 1], c=labels, cmap='viridis', alpha=0.5)\n",
|
1080 |
+
"plt.scatter(centroids[:, 0], centroids[:, 1], marker='x', c='red', s=200, linewidths=2)\n",
|
1081 |
+
"plt.text(centroids[0,0], centroids[0,1], 'Normal', fontsize=12, color='red')\n",
|
1082 |
+
"plt.text(centroids[1,0], centroids[1,1], 'Anomaly', fontsize=12, color='red')\n",
|
1083 |
+
"plt.title('KMeans Clustering')\n",
|
1084 |
+
"plt.xlabel('Feature 1')\n",
|
1085 |
+
"plt.ylabel('Feature 2')\n",
|
1086 |
+
"plt.show()\n"
|
1087 |
+
]
|
1088 |
+
},
|
1089 |
+
{
|
1090 |
+
"cell_type": "code",
|
1091 |
+
"execution_count": 29,
|
1092 |
+
"metadata": {},
|
1093 |
+
"outputs": [
|
1094 |
+
{
|
1095 |
+
"data": {
|
1096 |
+
"text/plain": [
|
1097 |
+
"329810"
|
1098 |
+
]
|
1099 |
+
},
|
1100 |
+
"execution_count": 29,
|
1101 |
+
"metadata": {},
|
1102 |
+
"output_type": "execute_result"
|
1103 |
+
}
|
1104 |
+
],
|
1105 |
+
"source": [
|
1106 |
+
"sum(labels==0)"
|
1107 |
+
]
|
1108 |
+
}
|
1109 |
+
],
|
1110 |
+
"metadata": {
|
1111 |
+
"kernelspec": {
|
1112 |
+
"display_name": "tensorflow",
|
1113 |
+
"language": "python",
|
1114 |
+
"name": "python3"
|
1115 |
+
},
|
1116 |
+
"language_info": {
|
1117 |
+
"codemirror_mode": {
|
1118 |
+
"name": "ipython",
|
1119 |
+
"version": 3
|
1120 |
+
},
|
1121 |
+
"file_extension": ".py",
|
1122 |
+
"mimetype": "text/x-python",
|
1123 |
+
"name": "python",
|
1124 |
+
"nbconvert_exporter": "python",
|
1125 |
+
"pygments_lexer": "ipython3",
|
1126 |
+
"version": "3.11.8"
|
1127 |
+
}
|
1128 |
+
},
|
1129 |
+
"nbformat": 4,
|
1130 |
+
"nbformat_minor": 2
|
1131 |
+
}
|