Chapter 3 Data
The data is the “Ames Housing Dataset”, provided at kaggle.com, which contains information about the sale of individual residential properties in Ames, Iowa from 2006 to 2010. The original dataset was compiled by Dean DeCock for use in data science education, and and is available online here: Ames Housing Dataset.
The data set contains 2919 observations and 80 explanatory variables, plus the variable of interest: Sales Price. Kaggle provided the data split into train and test sets.
# Import Train and Tests Datasets
train_raw<-read.csv("train.csv",stringsAsFactors = TRUE) # 1460 rows, 81 columns
test_raw<-read.csv("test.csv", stringsAsFactors = TRUE)
#Merge Datasets for preprocessing steps. Separate into train and test sets later for modeling and prediction.
test_raw$"SalePrice"<-0 # Create "SalePrice" feature for test set
data_full<- rbind(train_raw, test_raw) # Combine hdb_train and hdb_test
#Save ID column for submissiom
test_ID <-test_raw$Id## There are 1460 rows and 81 columns in the Train data-set.
## There are 1459 rows and 81 columns in the Test data-set.
## There are 2919 rows and 81 columns in the combined data-set.
Table 3.1 shows a snippet of the raw data including the first 10 rows and 10 columns plus SalesPrice.
| Id | MSSubClass | MSZoning | LotFrontage | LotArea | Street | Alley | LotShape | LandContour | Utilities | SalePrice |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 60 | RL | 65 | 8450 | Pave | NA | Reg | Lvl | AllPub | 208500 |
| 2 | 20 | RL | 80 | 9600 | Pave | NA | Reg | Lvl | AllPub | 181500 |
| 3 | 60 | RL | 68 | 11250 | Pave | NA | IR1 | Lvl | AllPub | 223500 |
| 4 | 70 | RL | 60 | 9550 | Pave | NA | IR1 | Lvl | AllPub | 140000 |
| 5 | 60 | RL | 84 | 14260 | Pave | NA | IR1 | Lvl | AllPub | 250000 |
| 6 | 50 | RL | 85 | 14115 | Pave | NA | IR1 | Lvl | AllPub | 143000 |
| 7 | 20 | RL | 75 | 10084 | Pave | NA | Reg | Lvl | AllPub | 307000 |
| 8 | 60 | RL | NA | 10382 | Pave | NA | IR1 | Lvl | AllPub | 200000 |
| 9 | 50 | RM | 51 | 6120 | Pave | NA | Reg | Lvl | AllPub | 129900 |
| 10 | 190 | RL | 50 | 7420 | Pave | NA | Reg | Lvl | AllPub | 118000 |