Week 3 - 2-Polynomial Regression
Week 3 - 2-Polynomial Regression
lines?
Not all relationships are linear.
Linear formula: y = mx + b
This is a “first order” or
“first degree” polynomial, as
the power of x is 1
Second order polynomial: y =
ax2 + bx + c
Third order: y = ax3 + bx2 + cx
+
d
Higher orders produce more
Beware overfitting
Don’t use more degrees than you need
Visualise you data first to see how complex of a
curve there might really be
Visualise the fit – is you curve going out of its way
to accommodate outliers?
A high r-squared simply means your curve fits your
training data well; but it may not be a good
predictor.
Later we’ll talk about more principled ways to
detect overfitting (train/test)
Look at an example
Numpy.polyfit() makes it easy
PolynomialRegression.ipynb