Multivariate Linear Regression
Last updated
Last updated
This is linear regression, but with multiple variables. So we have a new hypothesis function!
e.g. Think of each variable as a different feature. could be square footage, could be number of floors, etc.
Repeat until convergence {
...
}
We can condense this down to:
Repeat until convergence {
}
Feature scaling speeds up gradient descent and ensures gradient descent to converge.
We generally want the range of the feature to stay in either one of these intervals:
Summary:
We don't always have to stick to only having the features in the equation. We can derive more from existing features.
Examples:
What if we don't want a linear function to fit the data? What if we want a parabola, square root, cubic?
for
Let be a feature like age of house.
This is a way you can ensure feature scaling ( is range).
Plot # of iterations of gradient descent on x-axis and on y-axis.
Automatic convergence test: If is decreasing by less than , most likely has converged (but usually just use a graph because it's easier to see).
If is too large → loss function will diverge (yellow line)
If is too small → loss function will converge too slowly (green line).
If is good → loss function will decrease every epoch at a reasonable time.
Let our hypothesis be
To get a square root function from this:
Let . We have created a new feature ! So now we have: .
Note: Feature scaling is very important here! Imagine if you created a cubic function. Your new feature would then be , so the values would be very large.