Feature House Prices: Advanced Regression Techniques

Posted on Feb 1, 2020
The skills I demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.


In this blog, I will be discussing my procedure in the Kaggle competition Housing Prices: Advanced Regression Techniques. The goal of this competition is to predict the sale price of houses in Ames, Iowa, given 79 explanatory variables, which are describe here.

The full code and data for this article are available in my Github

Read Data

Concatenate training & test features

I concatenated features so I wouldn't have to impute missing values, transform features, etc. I also removed houses with ground living area greater than 4,500 square feet from the training sets.

SalePrice Distribution

SalePrice Distribution

Impute missing values

The plot below shows the number of missing values in columns with at least one missing value. 

Engineer features

I created new features for the dataset. The features were TotalSF, TotalPorchSF, and TotalBath. The code is shown below: 

Categorize MSSubClass and YrSold

Looking at the description below, the levels for the MSSubClass don't seem to have a natural order. So I decided to represent the MSSubClass as a categorical feature order rather than a numerical feature. Also decided to represent YrSold as a categorical feature because it allowed for a more flexible relationship with SalePrice. 

Transform features

To better highlight the recurring patterns in SalePrice, I transformed the MoSold feature using the code below:

I also transformed the highly skewed features using the code below

And I used pd.get_dummies to convert all categorical values into dummy variables. 

Removing outliers from training data

I fitted a linear model to the training data and removed examples with a studentized residual greater than 3. 

Define random search

The code below defines random search as a function, and I used random search to optimize hyperparameters for each of our models. I also used a 5-fold cross validation to score each iteration. 

Model Scores

Overall the models did well with Gradient Boosting performing the best. These are the scores for each model performance: 

  • Ridge: 0.0778
  • Lasso: 0.0796
  • SVR: 0.0712
  • LGBM: 0.0640
  • GBM: 0.0436

Creating Predictions and RSME

I stored the predictions of the based learners and stacked ensemble in a list. Then I averaged the predictions and gave a weight of 0.13 to the based learners and 0.35 to the stacked ensemble. My RSME score was 0.3848232


Overall the models seemed to perform well, but the RSME score seemed a little bit high, and this might be due to an error in the code. So in the future I will see what I can do to improve on the RSME. 

About Author

Related Articles

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans 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 boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis 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 seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI