pylops.Regression#

class pylops.Regression(*args, **kwargs)[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
taxisnumpy.ndarray

Elements along the \(t\)-axis.

orderint

Order of the regressed polynomial.

dtypestr, optional

Type of elements in input array.

namestr, optional

New in version 2.0.0.

Name of operator (to be used by pylops.utils.describe.describe)

Raises
TypeError

If taxis is not numpy.ndarray.

See also

LinearRegression

Linear regression

Notes

The Regression operator solves the following problem:

\[y_i = \sum_{n=0}^\text{order} x_n t_i^n \qquad \forall i=0,1,\ldots,N-1\]

where \(N\) represents the number of points in taxis. We can express this problem in a matrix form

\[\mathbf{y}= \mathbf{A} \mathbf{x}\]

where

\[\mathbf{y}= [y_0, y_1,\ldots,y_{N-1}]^T, \qquad \mathbf{x}= [x_0, x_1,\ldots,x_\text{order}]^T\]

and

\[\begin{split}\mathbf{A} = \begin{bmatrix} 1 & t_{0} & t_{0}^2 & \ldots & t_{0}^\text{order} \\ 1 & t_{1} & t_{1}^2 & \ldots & t_{1}^\text{order} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & t_{N-1} & t_{N-1}^2 & \ldots & t_{N-1}^\text{order} \end{bmatrix}_{N\times \text{order}+1}\end{split}\]
Attributes
shapetuple

Operator shape

explicitbool

Operator contains a matrix that can be solved explicitly (True) or not (False)

Methods

__init__(taxis, order[, dtype, name])

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, densesolver])

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.

reset_count()

Reset counters

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.

trace([neval, method, backend])

Trace of linear operator.

transpose()

Transpose this linear operator.

Examples using pylops.Regression#

Linear Regression

Linear Regression

Linear Regression
Polynomial Regression

Polynomial Regression

Polynomial Regression