{"cells":[{"metadata":{},"cell_type":"markdown","source":"## Question/problem: how much energy will a given building use on a given day?"},{"metadata":{"trusted":true},"cell_type":"code","source":"library(pacman)\np_load(tidyverse, magrittr, caret, data.table)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# load the data\nbuilding_metadata = fread(\"../input/ashrae-energy-prediction/building_metadata.csv\")\n\ntrain = fread(\"../input/ashrae-energy-prediction/train.csv\")\ntest = fread(\"../input/ashrae-energy-prediction/test.csv\")\n\nweather_train = fread(\"../input/ashrae-energy-prediction/weather_train.csv\")\nweather_test = fread(\"../input/ashrae-energy-prediction/weather_test.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"head(building_metadata)\ndim(building_metadata)\n\nhead(train)\ndim(train)\nhead(test)\ndim(test)\n\nhead(weather_train)\ndim(weather_train)\nhead(weather_test)\ndim(weather_test)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Cleaning the data\n- Merge building_metadata, weather_train, and train into a training set, and merge building_metadata,weather_test, and test into a test set.\n- Rbind the training and testing sets for cleaning purposes\n- Impute missing values (medianImpute for all numeric, mode impute for categorical)\n- Convert site 0 meter_reading from kBTU to kWh (due to error in the dataset)\n- Change year_built to age of building (to be more interpretable)\n- Undo Rbind to create models"},{"metadata":{"trusted":true},"cell_type":"code","source":"# Create dummy variables for being in training vs. test sets so we can pull them apart later\n\ntrain %<>% mutate(train_id = 1)\ntest %<>% mutate(train_id = 0)\n\nweather_train %<>% mutate(weather_train_id = 1)\nweather_test %<>% mutate(weather_train_id = 0)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Merge for training data\nmeta_train = left_join(train, building_metadata, by = \"building_id\")\nfull_train = left_join(meta_train, weather_train, by = c(\"site_id\", \"timestamp\"))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Merge for testing data\nmeta_test = left_join(test, building_metadata, by = \"building_id\")\nfull_test = left_join(meta_test, weather_test, by = c(\"site_id\", \"timestamp\"))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"head(full_train)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Model 1: Elasticnet"},{"metadata":{},"cell_type":"markdown","source":"## Model 2: Random Forest"},{"metadata":{},"cell_type":"markdown","source":"## Model 3: K Nearest Neighbors"},{"metadata":{},"cell_type":"markdown","source":"## Model 4: Neural Net?"}],"metadata":{"kernelspec":{"display_name":"R","language":"R","name":"ir"},"language_info":{"mimetype":"text/x-r-source","name":"R","pygments_lexer":"r","version":"3.4.2","file_extension":".r","codemirror_mode":"r"}},"nbformat":4,"nbformat_minor":4}