# LeastSquaresMethod¶

class LeastSquaresMethod(*args)

Base class for least square solvers.

Available constructors:

LeastSquaresMethod(proxy, weight, indices)

LeastSquaresMethod(proxy, indices)

LeastSquaresMethod(design)

Parameters
proxyDesignProxy

Input sample

weightsequence of float

Output weights

indicessequence of int

Indices allowed in the basis

design2-d sequence of float

A priori known design matrix

Notes

Solve the least-squares problem: Methods

 Build(\*args) Instanciate a decomposition method from its name. computeWeightedDesign(self[, whole]) Build the design matrix. getBasis(self) Accessor to the basis. getClassName(self) Accessor to the object’s name. Current indices accessor. getGramInverse(self) Get the inverse Gram matrix of input sample. Get the diagonal of the inverse Gram matrix. Get the trace of the inverse Gram matrix. getH(self) Get the projection matrix H. getHDiag(self) Get the diagonal of the projection matrix H. getId(self) Accessor to the object’s id. Accessor to the underlying implementation. Initial indices accessor. getInputSample(self) Input sample accessor. getName(self) Accessor to the object’s name. getWeight(self) Accessor to the weights. setName(self, name) Accessor to the object’s name. solve(self, rhs) Solve the least-squares problem. solveNormal(self, rhs) Solve the least-squares problem using normal equation. update(self, addedIndices, conservedIndices, …) Update the current decomposition.
__init__(self, \*args)

Initialize self. See help(type(self)) for accurate signature.

static Build(\*args)

Instanciate a decomposition method from its name.

Parameters
namestr

The name of the least-squares method Values are ‘QR’, ‘SVD’, ‘Cholesky’

proxyDesignProxy

Input sample

weightsequence of float, optional

Output weights

indicessequence of int

Indices allowed in the basis

design2-d sequence of float

A priori known design matrix

Returns
methodLeastSquaresMethod

The built method

computeWeightedDesign(self, whole=False)

Build the design matrix.

Parameters
wholebool, defaults to False

Whether to use the initial indices instead of the current indices

Returns
psiAkMatrix

The design matrix

getBasis(self)

Accessor to the basis.

Returns
basiscollection of Function

Basis.

getClassName(self)

Accessor to the object’s name.

Returns
class_namestr

The object class name (object.__class__.__name__).

getCurrentIndices(self)

Current indices accessor.

Returns
indicesIndices

Indices of the current decomposition in the global basis.

getGramInverse(self)

Get the inverse Gram matrix of input sample. Returns
cCovarianceMatrix

The inverse Gram matrix.

getGramInverseDiag(self)

Get the diagonal of the inverse Gram matrix. Returns
dPoint

The diagonal of the inverse Gram matrix.

getGramInverseTrace(self)

Get the trace of the inverse Gram matrix. Returns
xScalar

The trace of inverse Gram matrix.

getH(self)

Get the projection matrix H. Returns
hSymmetricMatrix

The projection matrix H.

getHDiag(self)

Get the diagonal of the projection matrix H. Returns
dPoint

The diagonal of H.

getId(self)

Accessor to the object’s id.

Returns
idint

Internal unique identifier.

getImplementation(self)

Accessor to the underlying implementation.

Returns
implImplementation

The implementation class.

getInitialIndices(self)

Initial indices accessor.

Returns
indicesIndices

Initial indices of the terms in the global basis.

getInputSample(self)

Input sample accessor.

Returns
inputSampleSample

Input sample.

getName(self)

Accessor to the object’s name.

Returns
namestr

The name of the object.

getWeight(self)

Accessor to the weights.

Returns
weightPoint

Weights.

setName(self, name)

Accessor to the object’s name.

Parameters
namestr

The name of the object.

solve(self, rhs)

Solve the least-squares problem. Parameters
bsequence of float

Second term of the equation

Returns
aPoint

The solution.

solveNormal(self, rhs)

Solve the least-squares problem using normal equation. Parameters
bsequence of float

Second term of the equation

Returns
xPoint

The solution.

update(self, addedIndices, conservedIndices, removedIndices, row=False)

Update the current decomposition.

Parameters