Design matrix:X has shape nĆ(d+1), with rows Aug(xiā)T.
Multiple linear regression model:
h(xiā)=w0ā+w1āxi(1)ā+āÆ+wdāxi(d)ā
Dot-product form:
h(xiā)=wā Aug(xiā)
The same normal equations apply. The optimal wā is unique iff the d+1 columns are linearly independent; otherwise there are infinitely many solutions, all with the same predictions and MSE.
One-hot encoding:k categories become k binary columns. Codes like Mon = 1, Tue = 2 would impose a meaningless order.
Dependence with an intercept: the k one-hot columns sum to the 1s column, so the columns are dependent and wā is not unique.
Dropping one category: the column space, predictions, and MSE do not change. The remaining kā1 one-hot coefficients are shifts from the dropped (baseline) category.
Linear in the parameters: linear regression fits functions that are linear combinations of features, such as
h(xiā)=w0ā+w1āxiā+w2āxi2ā
This is a plane in feature space (where the axes are x, x2, and h(x)), but a curve in (x,h(x)) space.
A parameter inside a nonlinear function, such as sin(w2āx), cannot be fit this way.
Adding features never increases training MSE, since the column space never shrinks.
Overfitting: test MSE can rise as features are added. Fit candidate models on training data and compare them on test data.
scikit-learn:LinearRegression().fit(features, y) adds the intercept itself. intercept_ is w0āā; coef_ contains the remaining coefficients.
If X already has the 1s column, pass fit_intercept=False.