{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "c:\\Users\\levim\\anaconda3\\envs\\experiments\\lib\\site-packages\\scipy\\__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.24.3\n", " warnings.warn(f\"A NumPy version >={np_minversion} and <{np_maxversion}\"\n" ] } ], "source": [ "import pandas as pd \n", "from datetime import datetime \n", "from datetime import date\n", "import matplotlib.pyplot as plt\n", "# import seaborn as sns\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", "\n", "### Load ALL data ###\n", "all_data = pd.read_csv(dataPATH + r\"\\long_merge.csv\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load selection of data" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\levim\\AppData\\Local\\Temp\\ipykernel_27084\\3547628995.py:5: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " extended_energy_data['date'] = pd.to_datetime(extended_energy_data['date'])\n" ] } ], "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 = extended energy data\n", "# Resampling back to 15 minutes and 1 hour\n", "eed_15m = extended_energy_data.resample('15T').mean()\n", "eed_1h = extended_energy_data.resample('60T').mean()" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "vscode": { "languageId": "ruby" } }, "outputs": [], "source": [ "# Assuming you want to apply a moving average window of size 3 on the 'column_name' column\n", "window_size = 12*4 # Half a day\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()" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([17591., 17652., 17713., 17775., 17836., 17897.]),\n", " [Text(17591.0, 0, '2018-03'),\n", " Text(17652.0, 0, '2018-05'),\n", " Text(17713.0, 0, '2018-07'),\n", " Text(17775.0, 0, '2018-09'),\n", " Text(17836.0, 0, '2018-11'),\n", " Text(17897.0, 0, '2019-01')])" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%matplotlib qt\n", "\n", "start_date = '2018-02-02'\n", "end_date = '2019-02-03'\n", "\n", "plt.plot(eed_15m['hvac_N'].loc[start_date:end_date])\n", "plt.plot(eed_15m['moving_average'].loc[start_date:end_date])\n", "plt.xticks(rotation=45)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "experiments", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.15" } }, "nbformat": 4, "nbformat_minor": 2 }