# pylops.Regression¶

class pylops.Regression(taxis, order, dtype='float64')[source]

Polynomial regression.

Creates an operator that applies polynomial regression to a set of points. Values along the t-axis must be provided while initializing the operator. The coefficients of the polynomial regression form the model vector to be provided in forward mode, while the values of the regression curve shall be provided in adjoint mode.

Parameters: taxis : numpy.ndarray Elements along the t-axis. order : int Order of the regressed polynomial. dtype : str, optional Type of elements in input array. TypeError If t is not numpy.ndarray.

LinearRegression
Linear regression

Notes

The Regression operator solves the following problem:

$y_i = \sum_{n=0}^{order} x_n t_i^n \qquad \forall i=1,2,...,N$

where $$N$$ represents the order of the chosen polynomial. We can express this problem in a matrix form

$\mathbf{y}= \mathbf{A} \mathbf{x}$

where

$\mathbf{y}= [y_1, y_2,...,y_N]^T, \qquad \mathbf{x}= [x_0, x_1,...,x_{order}]^T$

and

$\begin{split}\mathbf{A} = \begin{bmatrix} 1 & t_{1} & t_{1}^2 & .. & t_{1}^{order} \\ 1 & t_{2} & t_{2}^2 & .. & t_{1}^{order} \\ .. & .. & .. & .. & .. \\ 1 & t_{N} & t_{N}^2 & .. & t_{N}^{order} \\ \end{bmatrix}\end{split}$
Attributes: shape : tuple Operator shape explicit : bool Operator contains a matrix that can be solved explicitly (True) or not (False)

Methods

 __init__(taxis, order[, dtype]) Initialize this LinearOperator. adjoint() Hermitian adjoint. apply(t, x) Return values along y-axis given certain t location(s) along t-axis and regression coefficients x apply_columns(cols) Apply subset of columns of operator cond([uselobpcg]) Condition number of linear operator. conj() Complex conjugate operator div(y[, niter]) Solve the linear problem $$\mathbf{y}=\mathbf{A}\mathbf{x}$$. dot(x) Matrix-matrix or matrix-vector multiplication. eigs([neigs, symmetric, niter, uselobpcg]) Most significant eigenvalues of linear operator. matmat(X) Matrix-matrix multiplication. matvec(x) Matrix-vector multiplication. rmatmat(X) Matrix-matrix multiplication. rmatvec(x) Adjoint matrix-vector multiplication. todense([backend]) Return dense matrix. toimag([forw, adj]) Imag operator toreal([forw, adj]) Real operator tosparse() Return sparse matrix. transpose() Transpose this linear operator.
apply(t, x)[source]

Return values along y-axis given certain t location(s) along t-axis and regression coefficients x

Parameters: taxis : numpy.ndarray Elements along the t-axis. x : numpy.ndarray Regression coefficients dtype : str, optional Returns ———- y : numpy.ndarray Values along y-axis