Project 1 of 10, for Paul
House Price Predictor
Predict a house's price from its floor area, from 1,000 real sales: the best straight line found by formula, on foot by gradient descent, and by scikit-learn.
Act 6 needs a free account, so your work is saved as you go. Act 1 is open to everyone.
The brief
- PaulBefore I trust a model with anything real, I like to try it on data the whole world's already checked.
- PaulI've got a thousand house sales from near Seattle, floor area against price, and I want the best line through them.
- YahyaOkay, but best by what measure?
- PaulThat's exactly the right question, and the whiteboard's free if you want to work it out.
king_county_houses.csv holds 1,000 real house sales from King County, Washington, between May 2014 and May 2015: the date, the price in dollars, the floor area in square metres, and some columns for later.
In house_prices.py, find the straight line that guesses a price from a floor area, price = w * area + b, three ways, and check they agree:
- By a formula.
- By walking downhill, a step at a time, from
w = 0andb = 0. - With scikit-learn, the library most people use.
Print how far off the line's guesses typically are, in dollars. Then ask for a floor area and give the line's price for it, to the nearest thousand dollars. An area outside the sizes in the sales gets a warning instead of a price, and an answer that isn't a number gets told so.
By formula: w = 3515.36, b = -140390 By descent: w = 3515.36, b = -140390 scikit-learn: w = 3515.36, b = -140390 Root mean squared error: $288,893 Floor area in square metres? 150 A house of 150 square metres: about $387,000
What you learn
What's in it
- A guess with dials
- Two houses, one line
- How wrong is it?
- Square, then average
- The best line
- The best line, by formula
- Walking downhill in fog
- Finding the bottom
- Two dials, two slopes
- How Paul would walk it
- Units change the hill
- Square metres or hundreds
- Fix Yahya's version
- The best line, on foot
- The library way
- One column is still a table
- The price of a house
- Ship it