ContentsChapter 4 · Regression2 of 4

4.2

Basis functions

In this chapter
  1. 4.1Least squares
  2. 4.2Basis functions
  3. 4.3Overfitting and bias–variance
  4. 4.4Regularisation
Before you readHow can you fit a curve without changing the least-squares method?
Watch: Linear regression 3: Polynomial regression and basis functions · Herman Kamper

A basis function turns the input into a feature. Stack MM such features in ϕ(x)\phi(x) and fit a weighted sum:

y=wTϕ(x)=∑j=1Mwjϕj(x).y = w^T\phi(x) = \sum_{j=1}^{M} w_j\phi_j(x).

The prediction can be nonlinear in xx but it is still linear in the weights. The design matrix Φ\Phi has row ϕ(xi)T\phi(x_i)^T for observation ii so the normal equations are still ΦTΦw=ΦTy\Phi^T\Phi w = \Phi^T y

A polynomial basis uses 1,x,x2,…1, x, x^2, \ldots A Gaussian basis function is a bump centred at cc exp⁡(−(x−c)22s2)\exp\big(-\frac{(x-c)^2}{2s^2}\big) with width set by ss These bumps are also called radial basis functions (RBFs).

-4-2024-1-0.500.51
Switch bases and change how many functions the model uses. The faint curves are the weighted basis functions; the thick curve is their sum.
Recall
In what sense is a basis-function model still linear?
Recall
What is row ii of the design matrix Φ\Phi
Recall
Where is a Gaussian basis function largest?
Exercise
Give the row of Φ\Phi at x=−2x=-2 for the ordered basis (1,x,x2)(1,x,x^2)
Exercise
Fit y=wx2y = wx^2 by least squares to (1,1)(1,1) and (2,8)(2,8) Give ww as a fraction or to three decimal places.