LeastSquaresMethod

class LeastSquaresMethod(*args)

Base class for least square solvers.

Available constructors:

LeastSquaresMethod(proxy, weight, indices)

LeastSquaresMethod(proxy, indices)

Parameters:
proxy : DesignProxy

Input sample

weight : sequence of float

Output weights

indices : sequence of int

Indices allowed in the basis

Notes

Solve the least-squares problem:

\vect{a} = \argmin_{\vect{b} \in \Rset^P} ||y - \vect{b}^{\intercal} \vect{\Psi}(\vect{U})||^2

Attributes:
thisown

The membership flag

Methods

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

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

static Build(*args)

Instanciate a decomposition method from its name.

Parameters:
name : str

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

proxy : DesignProxy

Input sample

weight : sequence of float, optional

Output weights

indices : sequence of int

Indices allowed in the basis

Returns:
method : LeastSquaresMethod

The built method

computeWeightedDesign(whole=False)

Build the design matrix.

Parameters:
whole : bool, defaults to False

Whether to use the initial indices instead of the current indices

Returns:
psiAk : Matrix

The design matrix

getBasis()

Accessor to the basis.

Returns:
basis : collection of Function

Basis.

getClassName()

Accessor to the object’s name.

Returns:
class_name : str

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

getCurrentIndices()

Current indices accessor.

Returns:
indices : Indices

Indices of the current decomposition in the global basis.

getGramInverse()

Get the inverse Gram matrix of input sample.

G^{-1} = (X^T * X)^{-1}

Returns:
c : CovarianceMatrix

The inverse Gram matrix.

getGramInverseDiag()

Get the diagonal of the inverse Gram matrix.

diag(G^{-1}) = diag((X^T * X)^{-1})

Returns:
d : Point

The diagonal of the inverse Gram matrix.

getGramInverseTrace()

Get the trace of the inverse Gram matrix.

Tr(G^{-1}) = Tr(x^T * x)^{-1}

Returns:
x : Scalar

The trace of inverse Gram matrix.

getH()

Get the projection matrix H.

H = X * (X^T * X)^{-1} * X^T

Returns:
h : SymmetricMatrix

The projection matrix H.

getHDiag()

Get the diagonal of the projection matrix H.

H = X * (X^T * X)^{-1} * X^T

Returns:
d : Point

The diagonal of H.

getId()

Accessor to the object’s id.

Returns:
id : int

Internal unique identifier.

getImplementation(*args)

Accessor to the underlying implementation.

Returns:
impl : Implementation

The implementation class.

getInitialIndices()

Initial indices accessor.

Returns:
indices : Indices

Initial indices of the terms in the global basis.

getInputSample()

Input sample accessor.

Returns:
inputSample : Sample

Input sample.

getName()

Accessor to the object’s name.

Returns:
name : str

The name of the object.

getWeight()

Accessor to the weights.

Returns:
weight : Point

Weights.

setName(name)

Accessor to the object’s name.

Parameters:
name : str

The name of the object.

solve(rhs)

Solve the least-squares problem.

\vect{a} = \argmin_{\vect{x} \in \Rset^P} ||M\vect{x}-\vect{b}||^2

Parameters:
b : sequence of float

Second term of the equation

Returns:
a : Point

The solution.

solveNormal(rhs)

Solve the least-squares problem using normal equation.

M^T*M*x=M^T*b

Parameters:
b : sequence of float

Second term of the equation

Returns:
x : Point

The solution.

thisown

The membership flag

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

Update the current decomposition.

Parameters:
addedIndices : sequence of int

Indices of added basis terms.

conservedIndices : sequence of int

Indices of conserved basis terms.

removedIndices : sequence of int

Indices of removed basis terms.