2.2.6 · D5Linear & Logistic Regression
Question bank — Polynomial regression
True or false — justify
Polynomial regression is a non-linear learning algorithm.
False — it is ordinary linear regression run on transformed features; "linear" means linear in the parameters , and are just fixed known numbers per example.
You need a brand-new optimizer (not gradient descent or the normal equation) to fit a polynomial.
False — because the model is still linear in , the exact same normal equation and the same gradient descent apply unchanged.
A degree- polynomial always fits training data at least as well as a degree- one.
True — the lower-degree model is a special case (set the top coefficient to ), so the higher-degree fit can never have larger training error, only equal or smaller.
Lower training error means the model will do better on new data.
False — a high-degree model can drive training error to zero by memorizing noise, yet fail badly on unseen points; that gap is exactly the overfitting problem.
Feature scaling for polynomial features is optional and only affects speed.
False — with raw features and span orders of magnitude, making ill-conditioned; scaling can be the difference between a stable solution and a numerically garbage one.
The intercept column of 's in is just a formality with no effect.
False — it lets the curve shift vertically (); without it every polynomial would be forced through the origin, badly biasing the fit.
Adding an interaction term keeps the model linear in the parameters.
True — is a single precomputed number per example, so its coefficient enters linearly; it is just one more column in .
If a degree-2 fit passes exactly through all points, you should always prefer it over a straight line.
False — an exact fit on few points may be coincidence or overfit; you judge generalization on held-out data via validation, not on training error.
Spot the error
"We fit , so this is a non-linear model that gradient descent can't handle."
The error: dropping the linear term doesn't make it non-linear in ; is a known feature and gradient descent handles it fine.
"With 5 data points and a degree-4 polynomial, zero training error proves we found the true pattern."
The error: 5 parameters for 5 points guarantees an exact fit by construction, so zero error proves nothing about the underlying pattern — it is a red flag for overfitting.
"I scaled the original before creating , so scaling is done."
The error: scaling before transforming still leaves on different scales; you must scale after generating the polynomial features so each column has comparable magnitude.
"Higher degree lowers bias, so higher degree is always the safer choice."
The error: lowering bias raises variance (bias-variance tradeoff); pushing degree up eventually makes test error worse, not better.
" has rows because we have training examples."
The error: is because there are features (columns of ); the number of examples is the number of rows of , which cancels out in the product.
"To model two features up to degree 2, I only need and ."
The error: you also need the interaction term (and the linear terms) to capture how the two features jointly influence the target.
Why questions
Why does calling it "linear" regression not contradict fitting a curved parabola?
Because the curvature comes from the features (), while the fitted quantity is a straight-line combination of coefficients — linearity refers to the parameters, not the shape of the output curve.
Why does the normal equation become numerically unstable without scaling?
Widely different feature scales make columns of nearly dependent in floating point, so is near-singular and inverting it amplifies rounding errors enormously.
Why do we choose degree with a validation set instead of training error?
Training error only ever decreases (or stays flat) as degree rises, so it can't detect overfitting; validation error rises once the model starts memorizing noise, revealing the sweet spot.
Why can two features with an interaction term outperform two separate polynomial terms?
Because interactions capture joint effects (e.g. rainfall and heat together), which no sum of single-variable terms can represent — the effect of one feature depends on the value of the other.
Why does the derivation of look identical to plain linear regression?
Because once features are transformed, the least-squares problem is literally the same optimization in a new feature space; only the entries of changed, not the algebra.
Why might gradient descent be preferred over the normal equation for very high-degree polynomials?
The normal equation costs inverting a matrix and is fragile when it is ill-conditioned; gradient descent avoids the explicit inverse and scales better in feature count.
Edge cases
What happens if the polynomial degree satisfies (more parameters than examples)?
The system is underdetermined — infinitely many coefficient sets give zero training error, is singular, and the model overfits catastrophically.
What is a degree-0 polynomial regression, geometrically?
It is , a flat horizontal line at the mean of — it ignores entirely and represents maximum bias, minimum variance.
If all your values are identical, can you fit any polynomial degree ?
No — every column beyond the intercept becomes a constant, so has dependent columns, is singular, and no unique solution exists.
What does a degree-1 polynomial regression reduce to exactly?
Ordinary simple linear regression — polynomial regression is a strict generalization that contains the straight-line model as its degree-1 case.
If you standardize a feature that happens to already have mean 0 and std 1, what changes?
Nothing meaningful — subtracting and dividing by leaves the values unchanged, so scaling is a safe no-op on already-standardized features.
What happens to the fitted curve far outside the range of your training values?
High-degree polynomials shoot off to rapidly, so extrapolation beyond the data range is wildly unreliable regardless of how good the in-range fit looked.
Recall One-line self-check
Can you state, without looking, why "linear" regression can fit a parabola? ::: The output curves because features like are curved, but the model is a straight-line (linear) combination of the parameters .