Orthogonal least squares#

Orthogonal least squares and error reduction ratios.

For a linear-in-parameters model \(y = w_0 + \sum_{i=1}^m w_i F_i(\mathbf{x}) + e\), orthogonal least squares (OLS) orthogonalizes the regressor columns \(\boldsymbol\Phi=[\boldsymbol\phi_1,\dots,\boldsymbol\phi_m]\) into \(\mathbf{q}_1,\dots,\mathbf{q}_m\) and measures how much of the output energy each orthogonal direction explains, the error reduction ratio

\[\mathrm{ERR}_i = \frac{g_i^2\,\mathbf{q}_i^{\mathsf T}\mathbf{q}_i}{\mathbf{y}^{\mathsf T}\mathbf{y}}, \qquad g_i = \frac{\mathbf{q}_i^{\mathsf T}\mathbf{y}}{\mathbf{q}_i^{\mathsf T}\mathbf{q}_i}\]

(Chen, Billings and Luo, 1989). With an intercept, \(\mathbf{y}\) and the regressors are centered first, so that \(\sum_i\mathrm{ERR}_i=R^2\). Madár, Abonyi and Szeifert (2005) use the ERR values to prune the terms of genetic-programming models (GP-OLS); the forward selection forward_ols() is the FROLS algorithm of the NARMAX literature (Billings, 2013).

Examples#

>>> import numpy as np
>>> from eqdisco.ols import ols_err
>>> rng = np.random.default_rng(1)
>>> Phi = rng.normal(size=(200, 3))
>>> y = 2 * Phi[:, 0] + 0.1 * Phi[:, 2] + 0.01 * rng.normal(size=200)
>>> res = ols_err(Phi, y)
>>> np.round(res.err, 3)
array([0.998, 0.   , 0.002])
>>> np.round(res.coef, 2) + 0.0
array([2. , 0. , 0.1])

OLS with error reduction ratios and forward regression (FROLS).

Classes#

OLSResult(err, coef, intercept, order, r2[, ...])

Result of ols_err() and forward_ols().

Functions#

ols_err(Phi, y[, order, intercept, tol])

ERR of every regressor, orthogonalized in a given order (modified Gram--Schmidt).

forward_ols(Phi, y[, max_terms, err_tol, ...])

Forward regression with orthogonal least squares (FROLS).