{ "cells": [ { "cell_type": "code", "execution_count": 85, "metadata": {}, "outputs": [], "source": [ "import pandas as pd \n", "from datetime import datetime \n", "from datetime import date\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", "from keras.models import Sequential\n", "from keras.layers import LSTM, Dense\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.preprocessing import MinMaxScaler,StandardScaler\n", "from keras.callbacks import ModelCheckpoint\n", "\n", "dataPATH = r\"C:\\Users\\levim\\OneDrive\\Documents\\MastersAI_ES\\TeamProject-5ARIP10\\smart-buildings\\Data\"\n", "# all_data = pd.read_csv(dataPATH + r\"\\long_merge.csv\")\n", "all_data = pd.read_csv(dataPATH + r\"\\extended_energy_data.csv\")\n", "interpolated_data = pd.read_csv(dataPATH + r\"\\interpolated_energy_data.csv\", index_col=0)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Prepar energy data set with extended features\n", "feature_list = ['date', 'hvac_N', 'hvac_S', 'air_temp_set_1', 'solar_radiation_set_1']\n", "extended_energy_data = all_data[feature_list]\n", "\n", "extended_energy_data['date'] = pd.to_datetime(extended_energy_data['date'])\n", "extended_energy_data.set_index('date', inplace=True)\n", "\n", "eed_15m = extended_energy_data.resample('15T').mean()\n", "eed_1h = extended_energy_data.resample('60T').mean()\n", "\n", "eed_15m = eed_15m.reset_index(drop=False)\n", "eed_1h = eed_1h.reset_index(drop=False)\n", "\n", "window_size = 4*4 # 4 hours\n", "eed_15m_avg = eed_15m.copy()\n", "eed_15m_avg['hvac_N'] = eed_15m['hvac_N'].rolling(window=window_size).mean()\n", "eed_15m_avg['hvac_S'] = eed_15m['hvac_S'].rolling(window=window_size).mean()\n", "\n", "window_size = 4 # 4 hours\n", "eed_1h_avg = eed_1h.copy()\n", "eed_1h_avg['hvac_N'] = eed_1h['hvac_N'].rolling(window=window_size).mean()\n", "eed_1h_avg['hvac_S'] = eed_1h['hvac_S'].rolling(window=window_size).mean()\n", "\n", "eed_15m.head()" ] }, { "cell_type": "code", "execution_count": 86, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | date | \n", "hvac_N | \n", "hvac_S | \n", "day_of_week | \n", "air_temp_set_1 | \n", "solar_radiation_set_1 | \n", "
---|---|---|---|---|---|---|
0 | \n", "2018-01-02 00:00:00 | \n", "38.225000 | \n", "26.4000 | \n", "1 | \n", "14.9550 | \n", "87.4450 | \n", "
1 | \n", "2018-01-02 01:00:00 | \n", "38.297501 | \n", "21.1750 | \n", "1 | \n", "14.2125 | \n", "2.8675 | \n", "
2 | \n", "2018-01-02 02:00:00 | \n", "38.072500 | \n", "21.7225 | \n", "1 | \n", "14.2700 | \n", "0.0925 | \n", "
3 | \n", "2018-01-02 03:00:00 | \n", "39.147500 | \n", "21.7000 | \n", "1 | \n", "14.1375 | \n", "0.1175 | \n", "
4 | \n", "2018-01-02 04:00:00 | \n", "38.172500 | \n", "21.6250 | \n", "1 | \n", "13.9850 | \n", "0.0725 | \n", "