Week 1 Exercise 1 " value in the `hundreds of thousands`"

Hello @Ann_Maria.

There are two ideas in my responses that might be helpful to you.

One is that the grader is asking for the output to be expressed in specific units of measure - hundreds of thousands of dollars. In the real world, $400,000 (four hundred thousand dollars) 400 * $1,000 (four hundred thousand dollars) and 4 * $100,000 (four hundred thousand dollars) all buy the same house. Only the units of measure differ - just as an object’s weight is the same regardless if you express it in grams or kilograms. The grader is expecting the answer in hundred thousand dollars form. If you express it any other way, it will complain.

Turns out there are two ways to get to that unit of measure. You can scale the value returned by the prediction - after the model runs, or you can scale the housing prices in the y data - before the model runs. This is the second important idea of this exercise. The model used here has so few inputs, and the model is so simple, that it isn’t immediately apparent, but it turns out it can be important for model training performance if all the input and the output values have similar scale. That means the number of rooms, which is initially provided as order of magnitude 1 (all values less than 10) and the price, which is initially provided as order of magnitude 10^6 (all values in the hundreds of thousands) should be scaled, or normalized, to be in the same range. This would also be true if there were more features of the house being considered, say number of bedrooms (order of magnitude 1) and living space area (maybe order of magnitude 1000) . Scaling , or normalizing, the inputs up front can make the loss function better behaved and the gradients less steep, which results in better training and better predictions.

So the takeaways for this exercise are

  1. you want the model to produce a prediction value in the form of p * 10^6 dollars
  2. the preferred way to get to that scale of output is to normalize the prices to the same units of measure. In other words divide all the prices by 10^6 before you provide them to the model.

Hope this helps.

2 Likes