π€ Better Pizza Predictions with Multiple RegressionΒΆ
In π€ Predicting Pizza Prices - Linear Regression We developed a model for predicting pizza prices based on their diameter. In this section lets try to improve that model by using more data. In this case we will use both the diameter and the number of toppings.
Training Inst |
Diameter |
Toppings |
Price |
1 |
6 |
2 |
7 |
2 |
8 |
1 |
9 |
3 |
10 |
0 |
13 |
4 |
14 |
2 |
17.5 |
5 |
18 |
0 |
18 |
The question is how can we generalize the
Another way to write this is simply
In our higher dimensional space we are not really calculating the y coordinate but rather making a prediction for some value such as the pizza price based on the known quantities of some other variables weighted by the different coefficients. We still need the b term to ensure that our hyperplane does not have to pass through the origin of our multi-dimensional space. We can simplify the equation even more if we use the convention that
The reason this simplification is powerful and important is that we have now boiled down our prediction to taking the dot product of two vectors.
Weβll come back in a minute and talk about how we will calculate
Now that we have our dot product we can go back to the structure of our initial regression problem. If you recall what we did there, we tried fiddling with the values for m and b just a little bit and kept the modification that decreased our mean squared error (MSE). We will play the same game, but instead of changing m and b we will make small changes to each of the values
pizza_toppings.csv
Training Inst,Diameter,Toppings,Price 1,6,2,7 2,8,1,9 3,10,0,13 4,14,2,17.5 5,18,0,18
Now using the data above calculate the vector of coefficients for the bias, diameter and number of toppings. Your function should return a list corresponding to
You can improve upon the solution from π€ Predicting Pizza Prices - Linear Regression because you can now use a while loop
. You can have your program continue until your values for
Graphing the ErrorΒΆ
Now that you have written this algorithm it may be hard for you to visualize this as βlearning.β It seems like random updates more than intelligence. Yet, at each iteration the error gets a bit smaller. You can see this for yourself if you make a list of the error calculated each time through the loop and graph it over time using altair.
-
During this project I was primarily in my...
- 1. Comfort Zone
- 2. Learning Zone
- 3. Panic Zone
-
Completing this project took...
- 1. Very little time
- 2. A reasonable amount of time
- 3. More time than is reasonable
-
Based on my own interests and needs, the things taught in this project...
- 1. Don't seem worth learning
- 2. May be worth learning
- 3. Are definitely worth learning
-
For me to master the things taught in this project feels...
- 1. Definitely within reach
- 2. Within reach if I try my hardest
- 3. Out of reach no matter how hard I try