{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:01:26.194753Z","iopub.execute_input":"2022-01-10T11:01:26.195106Z","iopub.status.idle":"2022-01-10T11:01:26.200558Z","shell.execute_reply.started":"2022-01-10T11:01:26.195071Z","shell.execute_reply":"2022-01-10T11:01:26.199887Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"DATASET_PATH  = '../input/ashrae-energy-prediction/'","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:03:55.204393Z","iopub.execute_input":"2022-01-10T11:03:55.204738Z","iopub.status.idle":"2022-01-10T11:03:55.209385Z","shell.execute_reply.started":"2022-01-10T11:03:55.204702Z","shell.execute_reply":"2022-01-10T11:03:55.208448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset = pd.read_csv('../input/ashrae-energy-prediction/train.csv')\n","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:02:55.026282Z","iopub.execute_input":"2022-01-10T11:02:55.026637Z","iopub.status.idle":"2022-01-10T11:03:05.872227Z","shell.execute_reply.started":"2022-01-10T11:02:55.026592Z","shell.execute_reply":"2022-01-10T11:03:05.871222Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainData = dataset\ntrainData","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:03:15.097701Z","iopub.execute_input":"2022-01-10T11:03:15.098001Z","iopub.status.idle":"2022-01-10T11:03:17.417766Z","shell.execute_reply.started":"2022-01-10T11:03:15.097971Z","shell.execute_reply":"2022-01-10T11:03:17.416881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"buildingData = pd.read_csv(DATASET_PATH + 'building_metadata.csv')","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:04:32.921204Z","iopub.execute_input":"2022-01-10T11:04:32.921964Z","iopub.status.idle":"2022-01-10T11:04:32.934950Z","shell.execute_reply.started":"2022-01-10T11:04:32.921921Z","shell.execute_reply":"2022-01-10T11:04:32.933901Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"buildingData.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:04:55.180985Z","iopub.execute_input":"2022-01-10T11:04:55.181765Z","iopub.status.idle":"2022-01-10T11:04:55.192088Z","shell.execute_reply.started":"2022-01-10T11:04:55.181722Z","shell.execute_reply":"2022-01-10T11:04:55.190999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Merging building data with training data","metadata":{}},{"cell_type":"code","source":"data = dataset.merge(buildingData,on = 'building_id',how = 'left')","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:05:12.182810Z","iopub.execute_input":"2022-01-10T11:05:12.183169Z","iopub.status.idle":"2022-01-10T11:05:16.135977Z","shell.execute_reply.started":"2022-01-10T11:05:12.183121Z","shell.execute_reply":"2022-01-10T11:05:16.135020Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Removing features having alot of nulls ","metadata":{}},{"cell_type":"code","source":"data = data.drop('year_built',axis = 1)\ndata = data.drop('floor_count',axis = 1)","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:05:18.962159Z","iopub.execute_input":"2022-01-10T11:05:18.962463Z","iopub.status.idle":"2022-01-10T11:05:22.413861Z","shell.execute_reply.started":"2022-01-10T11:05:18.962424Z","shell.execute_reply":"2022-01-10T11:05:22.412974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#DATA_PATH = \"D:Study/Machine Learning/ML Project/\"\nweather_train = pd.read_csv(DATASET_PATH + 'weather_train.csv')\nweather_test = weather_df = pd.read_csv(DATASET_PATH + 'weather_test.csv')","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:05:41.762975Z","iopub.execute_input":"2022-01-10T11:05:41.763265Z","iopub.status.idle":"2022-01-10T11:05:42.226685Z","shell.execute_reply.started":"2022-01-10T11:05:41.763235Z","shell.execute_reply":"2022-01-10T11:05:42.225453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Concatinating weather train and weather test data","metadata":{}},{"cell_type":"code","source":"import datetime as dt\nframes = [weather_train,weather_test]\nweather_data = pd.concat(frames)\ndata = data.merge(weather_data, on=['site_id', 'timestamp'], how='left')\n","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:06:22.972102Z","iopub.execute_input":"2022-01-10T11:06:22.972438Z","iopub.status.idle":"2022-01-10T11:06:29.407672Z","shell.execute_reply.started":"2022-01-10T11:06:22.972402Z","shell.execute_reply":"2022-01-10T11:06:29.406743Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Converting timestamp feature to datetime to extract another features such as day,hour,month,and year","metadata":{}},{"cell_type":"code","source":"data[\"timestamp\"] = pd.to_datetime(data[\"timestamp\"])\ndata[\"day\"]       = data[\"timestamp\"].dt.day\ndata[\"hour\"]      = data[\"timestamp\"].dt.hour\ndata[\"week\"]      = data[\"timestamp\"].dt.weekday\ndata[\"month\"]     = data[\"timestamp\"].dt.month\ndata[\"year\"]      = data[\"timestamp\"].dt.year\ndata              = data.drop(\"timestamp\", axis = 1)\ndel weather_data","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:06:52.436310Z","iopub.execute_input":"2022-01-10T11:06:52.437171Z","iopub.status.idle":"2022-01-10T11:07:09.286812Z","shell.execute_reply.started":"2022-01-10T11:06:52.437130Z","shell.execute_reply":"2022-01-10T11:07:09.285870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:07:18.396820Z","iopub.execute_input":"2022-01-10T11:07:18.397870Z","iopub.status.idle":"2022-01-10T11:07:18.436842Z","shell.execute_reply.started":"2022-01-10T11:07:18.397809Z","shell.execute_reply":"2022-01-10T11:07:18.436105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:07:23.414749Z","iopub.execute_input":"2022-01-10T11:07:23.415558Z","iopub.status.idle":"2022-01-10T11:07:26.226969Z","shell.execute_reply.started":"2022-01-10T11:07:23.415519Z","shell.execute_reply":"2022-01-10T11:07:26.226069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Removing useless features","metadata":{}},{"cell_type":"code","source":"data.isnull().sum()","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# precip_depth_1_hr\ndata = data.drop('cloud_coverage',axis = 1)\ndata","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:07:34.086924Z","iopub.execute_input":"2022-01-10T11:07:34.087468Z","iopub.status.idle":"2022-01-10T11:07:35.199557Z","shell.execute_reply.started":"2022-01-10T11:07:34.087422Z","shell.execute_reply":"2022-01-10T11:07:35.198943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = data.drop(['wind_direction','sea_level_pressure'],axis=1)\ndata","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:07:41.000223Z","iopub.execute_input":"2022-01-10T11:07:41.001170Z","iopub.status.idle":"2022-01-10T11:07:42.003872Z","shell.execute_reply.started":"2022-01-10T11:07:41.001116Z","shell.execute_reply":"2022-01-10T11:07:42.003052Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Filling missing data","metadata":{}},{"cell_type":"code","source":"data['air_temperature'] = data['air_temperature'].fillna(data['air_temperature'].mean())\ndata['wind_speed'] = data['wind_speed'].fillna(data['wind_speed'].mean())\ndata['dew_temperature'] = data['dew_temperature'].fillna(data['dew_temperature'].mean())\ndata['precip_depth_1_hr'] = data['precip_depth_1_hr'].fillna(data['precip_depth_1_hr'].mean())","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:07:54.342145Z","iopub.execute_input":"2022-01-10T11:07:54.342438Z","iopub.status.idle":"2022-01-10T11:07:55.271642Z","shell.execute_reply.started":"2022-01-10T11:07:54.342409Z","shell.execute_reply":"2022-01-10T11:07:55.270724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del dataset","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:08:39.956638Z","iopub.execute_input":"2022-01-10T11:08:39.957499Z","iopub.status.idle":"2022-01-10T11:08:40.026773Z","shell.execute_reply.started":"2022-01-10T11:08:39.957459Z","shell.execute_reply":"2022-01-10T11:08:40.025870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.describe()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:07:59.814738Z","iopub.execute_input":"2022-01-10T11:07:59.815074Z","iopub.status.idle":"2022-01-10T11:08:10.626531Z","shell.execute_reply.started":"2022-01-10T11:07:59.815040Z","shell.execute_reply":"2022-01-10T11:08:10.625794Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Fixing side_id 0 error","metadata":{}},{"cell_type":"code","source":"data['meter_reading'] = [j*0.2931 if i == 0 else j for i,j in zip(data['site_id'],data['meter_reading'])]\ndata","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:09:05.049808Z","iopub.execute_input":"2022-01-10T11:09:05.050136Z","iopub.status.idle":"2022-01-10T11:09:17.524791Z","shell.execute_reply.started":"2022-01-10T11:09:05.050104Z","shell.execute_reply":"2022-01-10T11:09:17.523893Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"meter_values = data['meter'].unique()\nmeter_values","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:09:29.401648Z","iopub.execute_input":"2022-01-10T11:09:29.402183Z","iopub.status.idle":"2022-01-10T11:09:29.523079Z","shell.execute_reply.started":"2022-01-10T11:09:29.402131Z","shell.execute_reply":"2022-01-10T11:09:29.522157Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Filtering buildings that use electricity meter","metadata":{}},{"cell_type":"code","source":"electricMeter = data[data['meter']==0]\n","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:09:31.473913Z","iopub.execute_input":"2022-01-10T11:09:31.474235Z","iopub.status.idle":"2022-01-10T11:09:32.462647Z","shell.execute_reply.started":"2022-01-10T11:09:31.474202Z","shell.execute_reply":"2022-01-10T11:09:32.461791Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Graph shows the correlation between electricity meter and air temperature","metadata":{}},{"cell_type":"code","source":"plt.scatter(electricMeter['meter_reading'],electricMeter['air_temperature'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:09:34.985145Z","iopub.execute_input":"2022-01-10T11:09:34.986045Z","iopub.status.idle":"2022-01-10T11:09:55.784552Z","shell.execute_reply.started":"2022-01-10T11:09:34.985978Z","shell.execute_reply":"2022-01-10T11:09:55.783840Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Filtering buildings by meter","metadata":{}},{"cell_type":"code","source":"chilledWaterMeter = data[data['meter']==1]\nstemMeter = data[data['meter']==2]\nhotWaterMeter = data[data['meter']==3]","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:10:30.023803Z","iopub.execute_input":"2022-01-10T11:10:30.024876Z","iopub.status.idle":"2022-01-10T11:10:31.852055Z","shell.execute_reply.started":"2022-01-10T11:10:30.024822Z","shell.execute_reply":"2022-01-10T11:10:31.850997Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Graph shows the correlation between chilled water meter and air temperature","metadata":{}},{"cell_type":"code","source":"plt.scatter(chilledWaterMeter['meter_reading'],chilledWaterMeter['air_temperature'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:10:36.788901Z","iopub.execute_input":"2022-01-10T11:10:36.789672Z","iopub.status.idle":"2022-01-10T11:10:44.445440Z","shell.execute_reply.started":"2022-01-10T11:10:36.789598Z","shell.execute_reply":"2022-01-10T11:10:44.444701Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Graph shows the correlation between stem meter and air temperature","metadata":{}},{"cell_type":"code","source":"plt.scatter(stemMeter['meter_reading'],stemMeter['air_temperature'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:10:51.007057Z","iopub.execute_input":"2022-01-10T11:10:51.007369Z","iopub.status.idle":"2022-01-10T11:10:55.938362Z","shell.execute_reply.started":"2022-01-10T11:10:51.007339Z","shell.execute_reply":"2022-01-10T11:10:55.937346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Graph shows the correlation between hot water meter and air temperature","metadata":{}},{"cell_type":"code","source":"plt.scatter(hotWaterMeter['meter_reading'],hotWaterMeter['air_temperature'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:11:00.859397Z","iopub.execute_input":"2022-01-10T11:11:00.859732Z","iopub.status.idle":"2022-01-10T11:11:03.287598Z","shell.execute_reply.started":"2022-01-10T11:11:00.859699Z","shell.execute_reply":"2022-01-10T11:11:03.286439Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Removing outliers","metadata":{}},{"cell_type":"markdown","source":"**there are outliers values  in buildings that use electricity meter and hot water**","metadata":{}},{"cell_type":"markdown","source":"***Electricity Meter Outliers***","metadata":{}},{"cell_type":"code","source":"mask1 = data[\"meter\"] == 0\nmask2 = data[\"meter_reading\"] > 40000\nmask = np.logical_and(mask1, mask2)\nprint(data.shape)\ndata[mask][\"meter_reading\"] = data[mask1][\"meter_reading\"].mean()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:11:15.900695Z","iopub.execute_input":"2022-01-10T11:11:15.901456Z","iopub.status.idle":"2022-01-10T11:11:19.181687Z","shell.execute_reply.started":"2022-01-10T11:11:15.901411Z","shell.execute_reply":"2022-01-10T11:11:19.179722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"***Hot water Meter Outliers***","metadata":{}},{"cell_type":"code","source":"mask1 = data[\"meter\"] == 3\nmask2 = data[\"meter_reading\"] > 140000\nmask = np.logical_and(mask1, mask2)\nprint(data.shape)\ndata[mask][\"meter_reading\"] = data[mask1][\"meter_reading\"].mean()\nprint(data.shape)","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:11:36.650997Z","iopub.execute_input":"2022-01-10T11:11:36.652029Z","iopub.status.idle":"2022-01-10T11:11:36.929456Z","shell.execute_reply.started":"2022-01-10T11:11:36.651969Z","shell.execute_reply":"2022-01-10T11:11:36.928285Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Mean of using electricity meter per month ","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==0]\nnewData.index = newData['month']\nnewData.drop(columns = 'month')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['month','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (15,7))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:11:51.830533Z","iopub.execute_input":"2022-01-10T11:11:51.830930Z","iopub.status.idle":"2022-01-10T11:11:56.613609Z","shell.execute_reply.started":"2022-01-10T11:11:51.830895Z","shell.execute_reply":"2022-01-10T11:11:56.612480Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Mean of using Chilled Water meter per month ","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==1]\nnewData.index = newData['month']\nnewData.drop(columns = 'month')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['month','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (15,7))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:12:02.296514Z","iopub.execute_input":"2022-01-10T11:12:02.296851Z","iopub.status.idle":"2022-01-10T11:12:03.429554Z","shell.execute_reply.started":"2022-01-10T11:12:02.296817Z","shell.execute_reply":"2022-01-10T11:12:03.428474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Mean of using Stem meter per month ","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==2]\nnewData.index = newData['month']\nnewData.drop(columns = 'month')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['month','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (15,7))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:12:07.460065Z","iopub.execute_input":"2022-01-10T11:12:07.460512Z","iopub.status.idle":"2022-01-10T11:12:08.326377Z","shell.execute_reply.started":"2022-01-10T11:12:07.460373Z","shell.execute_reply":"2022-01-10T11:12:08.325176Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Mean of using Hot Water meter per month ","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==3]\nnewData.index = newData['month']\nnewData.drop(columns = 'month')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['month','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (15,7))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:12:25.426102Z","iopub.execute_input":"2022-01-10T11:12:25.426415Z","iopub.status.idle":"2022-01-10T11:12:25.962545Z","shell.execute_reply.started":"2022-01-10T11:12:25.426384Z","shell.execute_reply":"2022-01-10T11:12:25.961783Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Mean of using electricity meter per hour ","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==0]\nnewData.index = newData['hour']\nnewData.drop(columns = 'hour')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['hour','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (15,7))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:12:31.934103Z","iopub.execute_input":"2022-01-10T11:12:31.935031Z","iopub.status.idle":"2022-01-10T11:12:36.356428Z","shell.execute_reply.started":"2022-01-10T11:12:31.934987Z","shell.execute_reply":"2022-01-10T11:12:36.355411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Mean of using Chilled Water meter per hour","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==1]\nnewData.index = newData['hour']\nnewData.drop(columns = 'hour')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['hour','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (15,7))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:12:40.762338Z","iopub.execute_input":"2022-01-10T11:12:40.763524Z","iopub.status.idle":"2022-01-10T11:12:42.406934Z","shell.execute_reply.started":"2022-01-10T11:12:40.763465Z","shell.execute_reply":"2022-01-10T11:12:42.406152Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Mean of using Stem meter per hour ","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==2]\nnewData.index = newData['hour']\nnewData.drop(columns = 'hour')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['hour','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (15,7))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:12:46.390935Z","iopub.execute_input":"2022-01-10T11:12:46.391552Z","iopub.status.idle":"2022-01-10T11:12:47.505273Z","shell.execute_reply.started":"2022-01-10T11:12:46.391504Z","shell.execute_reply":"2022-01-10T11:12:47.504397Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Mean of using Hot Water meter per hour","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==3]\nnewData.index = newData['hour']\nnewData.drop(columns = 'hour')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['hour','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (15,7))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:12:51.142268Z","iopub.execute_input":"2022-01-10T11:12:51.142762Z","iopub.status.idle":"2022-01-10T11:12:51.989705Z","shell.execute_reply.started":"2022-01-10T11:12:51.142717Z","shell.execute_reply":"2022-01-10T11:12:51.988598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Usage of different types of buildings that use Electricity meter","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==0]\nnewData.index = newData['primary_use']\nnewData.drop(columns = 'primary_use')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['primary_use','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (15,7))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:13:04.162178Z","iopub.execute_input":"2022-01-10T11:13:04.162515Z","iopub.status.idle":"2022-01-10T11:13:31.766578Z","shell.execute_reply.started":"2022-01-10T11:13:04.162484Z","shell.execute_reply":"2022-01-10T11:13:31.765582Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Usage of different types of buildings that use Chilled Water meter","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==1]\nnewData.index = newData['primary_use']\nnewData.drop(columns = 'primary_use')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['primary_use','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (24,11))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:13:43.986516Z","iopub.execute_input":"2022-01-10T11:13:43.986846Z","iopub.status.idle":"2022-01-10T11:13:52.784285Z","shell.execute_reply.started":"2022-01-10T11:13:43.986815Z","shell.execute_reply":"2022-01-10T11:13:52.783581Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Usage of different types of buildings that use Stem meter","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==2]\nnewData.index = newData['primary_use']\nnewData.drop(columns = 'primary_use')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['primary_use','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (25,17))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:14:24.009125Z","iopub.execute_input":"2022-01-10T11:14:24.009823Z","iopub.status.idle":"2022-01-10T11:14:29.815090Z","shell.execute_reply.started":"2022-01-10T11:14:24.009784Z","shell.execute_reply":"2022-01-10T11:14:29.812287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Usage of different types of buildings that use Hot Water meter","metadata":{}},{"cell_type":"code","source":"newData = data[data['meter']==3]\nnewData.index = newData['primary_use']\nnewData.drop(columns = 'primary_use')\nnewData.sort_index(inplace = True)\ndata_to_plot = newData.groupby([newData.index])['primary_use','meter_reading'].mean()\nidx = data_to_plot.index\nmeter = data_to_plot.meter_reading\nplt.style.use('ggplot')\nplt.figure(figsize = (25,17))\nplt.plot(idx,meter,'-bo',label = 'meter_reading')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-10T11:14:42.328282Z","iopub.execute_input":"2022-01-10T11:14:42.329083Z","iopub.status.idle":"2022-01-10T11:14:45.244336Z","shell.execute_reply.started":"2022-01-10T11:14:42.329037Z","shell.execute_reply":"2022-01-10T11:14:45.243317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.isnull().sum()","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Converting primary use to numiric","metadata":{}},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"le = LabelEncoder()\ndata['primary_use'] = le.fit_transform(data['primary_use'])","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data","metadata":{},"execution_count":null,"outputs":[]}]}