Spaces:
Sleeping
Sleeping
File size: 4,614 Bytes
6a833f6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
{
"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
}
|