gemseo.mlearning.linear_model_fitting package#

Linear model fitting algorithms.

A linear model assumes that the relationship between the output scalar variables \(y_1,\ldots,y_p\) and the input scalar variables \(x_1,\ldots,x_d\) is linear, i.e.

\[y_j = w_0 + w_1 x_1 + \ldots + w_d x_d.\]

where \(w_1,\ldots,w_d\) are the weights.

The input variables (resp. output variables) are also called regressors, explanatory variables, predictors, or independent variables (resp. responses, targets or dependent variables).

Given \(n\) observations of these variables, we obtain:

\[y_j^{(i)} = w_{0,j} + w_{1,j} x_1^{(i)} + \ldots + w_{d,j} x_d^{(i)},\qquad i=1,\ldots,n, \quad j=1,\ldots,p\]

This system of \(n\) equations can be written in matrix notation as

\[Y = Xw\]

where

\[ \begin{align}\begin{aligned}\begin{split}X = \left(\begin{matrix}x_1^{(1)} & \ldots & x_d^{(1)} \\ \vdots & \ddots & \vdots \\ x_1^{(n)} & \ldots & x_d^{(n)}\end{matrix}\right)\in\mathcal{M}_{n,d}(\mathbb{R})\end{split}\\\begin{split}Y = \left(\begin{matrix}y_1^{(1)} & \ldots & y_p^{(1)} \\ \vdots & \ddots & \vdots \\ y_1^{(n)} & \ldots & y_p^{(n)}\end{matrix}\right)\in\mathcal{M}_{n,p}(\mathbb{R})\end{split}\\\begin{split}w = \left(\begin{matrix}w_{1,1} & \ldots & w_{1,p} \\ \vdots & \ddots & \vdots \\ w_{d,1} & \ldots & w_{d,p}\end{matrix}\right)\in\mathcal{M}_{d,p}(\mathbb{R})\end{split}\end{aligned}\end{align} \]

This package proposes different algorithms to fit such a linear model, i.e. finding the weights \(w\) minimizing \(\|Y-Xw\|\). These linear model fitting algorithms derive from the base class BaseLinearModelFitter which is equipped with BaseLinearModelFitter_Settings and can be created from a LinearModelFitterFactory.

The available algorithms are LinearRegression, Lasso, Ridge, LARS, ElasticNet and OrthogonalMatchingPursuit.

Submodules#