{"cells":[{"metadata":{},"cell_type":"markdown","source":"## A beginner's EDA on ASHRAE- Great Energy Predictor III"},{"metadata":{},"cell_type":"markdown","source":"#### In this notebook I have tried to explore multiple features and extract possible insights"},{"metadata":{},"cell_type":"markdown","source":"<img src=\"https://upload.wikimedia.org/wikipedia/en/f/fa/American_Society_of_Heating%2C_Refrigerating_and_Air-Conditioning_Engineers_Logo.svg\">"},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt  \nimport seaborn as sns\nfrom plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot\nimport cufflinks as cf\ncf.go_offline()\ncf.set_config_file(offline=False, world_readable=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train = pd.read_csv('../input/ashrae-energy-prediction/train.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"building = pd.read_csv('../input/ashrae-energy-prediction/building_metadata.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"building.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"results = train.join(building, how='outer',lsuffix='_x', rsuffix='_y')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"weather_train = pd.read_csv('../input/ashrae-energy-prediction/weather_train.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data = results.join(weather_train, how='outer',lsuffix='_X', rsuffix='_Y')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#Drop redundant columns\ndel data['building_id_y']\ndel data['timestamp_Y']\ndel data['site_id_Y']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"len(data['building_id_x'].unique())","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#There are 1449 Unique Building","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"groups = data.groupby('primary_use')['primary_use'].count()\ngroups.plot.bar(color='xkcd:lightish blue',alpha=0.5)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from matplotlib.pyplot import figure\nfigure(figsize=(30, 10))\ngroups = data.groupby('year_built')['year_built'].count()\ngroups.plot.bar(color='xkcd:lightish blue',alpha=0.5)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from plotly import graph_objs as go\n\nfig = go.Figure()\nfor name, group in data.groupby('year_built'):\n    trace = go.Histogram()\n    trace.name = name\n    trace.x = group['year_built']\n    fig.add_trace(trace)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fig","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"##### Plot for # of buildings built in a particular year"},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.set(rc={'figure.figsize':(11,8)})\nsns.set(style=\"whitegrid\")\nfig, ax = plt.subplots(1,1,figsize=(14, 6))\nax.set(xlabel='Year Built', ylabel='# Of Buildings', title='Buildings built in each year')\ndata['year_built'].value_counts(dropna=False).sort_index().plot(ax=ax)\n# data['year_built'].value_counts(dropna=False).sort_index().plot(ax=ax)\nax.legend(['Train', 'Test']);","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"##### Boxplots for Meter reading vs X"},{"metadata":{"trusted":true},"cell_type":"code","source":"fig, axes = plt.subplots(1, 1, figsize=(14, 6))\nsns.boxplot(x='site_id_X', y='meter_reading', data=data, showfliers=False);","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fig, axes = plt.subplots(1, 1, figsize=(50, 20))\nsns.boxplot(x='year_built', y='meter_reading', data=data, showfliers=False);","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fig, axes = plt.subplots(1, 1, figsize=(14, 6))\nsns.boxplot(x='site_id_X', y='air_temperature', data=data, showfliers=False);","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fig, axes = plt.subplots(1, 1, figsize=(14, 6))\nsns.boxplot(x='site_id_X', y='cloud_coverage', data=data, showfliers=False);","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fig, axes = plt.subplots(1, 1, figsize=(14, 6))\nsns.boxplot(x='site_id_X', y='dew_temperature', data=data, showfliers=False);","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"###### Scatter plot B/w Air Temperature and Meter Reading"},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.scatterplot(x='air_temperature', y='meter_reading', hue='year_built',data=data)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"##### Scatter plot B/w Cloud Coverage and Meter Reading"},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.scatterplot(x='cloud_coverage', y='meter_reading', hue='year_built',data=data)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"##### As cloud coverage increases Meter readings come down!"},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.scatterplot(x='air_temperature', y='meter_reading', data=data)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"##### Boxplots for Meter reading for Floorcounts"},{"metadata":{"trusted":true},"cell_type":"code","source":"fig, axes = plt.subplots(1, 1, figsize=(14, 6))\nsns.boxplot(x='floor_count', y='meter_reading', data=data, showfliers=False);","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"#### This is the end of my first introductory EDA"},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","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.7.3"}},"nbformat":4,"nbformat_minor":1}