Machine Learning - Ames, IA

Nathan
Posted on Aug 15, 2020

Thanks for reading this article! I'll try to make it straightforward for you so you can find what you're looking for!

Workflow

I largely broke this project in to 3 stages:

  1. Data preprocessing
  2. Model Experimentation
  3. Hyperparameter tuning and final selection

Data Preprocessing

In data preprocessing I dealt the the following topics:

  1. Missing values
  2. Outliers and apparently incorrect data
  3. Multicolinearity
  4. Feature Variance

Missingness

In many features, an NA value indicates None or Zero (absence of feature rather than absence of data) and in so in those instances I imputed the appropriate value. In particular, in many categorical values, NA indicated that the property was missing that feature, and so in those instances I imputed a "None" value. Purportedly, missing values in LotFrontage indicate that the lot has no contact with the street, so I imputed zeros for missing values in that variable.

When NA indicated missing data, I generally imputed the mean, median, mode, or a random value based on data type and skew. For example, data for the MasVnrArea feature was highly skewed to the right, so I imputed the median for NAs in that value. The Electical variable had one lonely missing value and apparently nearly all properties in Ames use a standard circuit breaker, so I imputed the mode but also removed this feature from later models.

In a few specialty cases I used a different strategy, such as GarageYrBlt, where I imputed the year the house was constructed.

Outliers and Apparently Incorrect Data

I evaluated features with highest correlation value with SalePrice (correlation greater than .6) using visualization for outliers and in instances where features had apparent outliers I removed them. I also inspected SalePrice and SalePrice by neighborhood and year and removed a few points that represented obvious outliers. At this point I also discovered that data for one of the neighborhoods (Veenker) seemed to be missing several year's worth of data and since it seemed unlikely that an entire neighborhood would see no sales for two years I reasoned this was the result of poor data gathering and removed it from the dataset.

 

 

I also noticed a number of instances in which MasVnrArea (the area of masonry veneer on the house) was listed as a non-zero, but the house's masonry type was listed as "None". This seemed like obvious incorrect recording and so I deleted these rows from the dataset.

Features with High Multicolinearity

A number of features possessed high multicolinearity (correlation > .6). For each cluster of correlated points I considered their relationship with SalePrice and removed the feature with lower correlation. In some instances I considered feature skew or variance as a tie-breaker. I also removed a MSZoning because most neighborhoods only had one type of zoning.

Feature Variance

I considered a range of thresholds for feature variance, but found that while removing features with low variance improved later model fit on most model types, it also widened the gap between train score (r2) and test score, which I judged to indicate overfitting. As a result I did not remove any features with low variance.

Model Experimentation

Following data preprocessing I performed an 80/20 train/test split on the data and assigned dummy variables to my categoricals using pd.get_dummies. I considered untuned (default settings, with the exception of random forest, where I set n_estimators to 100 to improve runtime) and tuned versions of Multiple Linear Regression, Lasso, Random Forest, XGBoost, and SVR (tuning strategies below).

I found that a tuned XGBoost offered the best score both for train and test set fit (again using R2 as our metric). 

 

About Author

Nathan

Nathan

Data scientist in training with a background in education and a passion for solving challenges using data-driven decision-making. Methodological, tenacious self-starter. Building skills with Python, R, SQL, statistical analysis, and machine learning models. Ask me where I am...
View all posts by Nathan >

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp