LinearLeastSquares

class LinearLeastSquares(*args)

First order polynomial response surface by least squares.

Parameters:
dataIn2-d sequence of float

Input data.

dataOut2-d sequence of float

Output data.`.

Methods

getCenter()

Get the centering vector of the approximation.

getClassName()

Accessor to the object's name.

getConstant()

Get the constant vector of the approximation.

getInputSample()

Get the input data.

getLinear()

Get the linear matrix of the approximation.

getName()

Accessor to the object's name.

getOutputSample()

Get the output data.

getResult()

Get the meta model result class.

hasName()

Test if the object is named.

run()

Perform the least squares approximation.

setDataOut(dataOut)

Set the output data.

setName(name)

Accessor to the object's name.

getDataIn

getDataOut

getMetaModel

Notes

A least squares meta model provides an approximation of the model which is valid over its whole domain of definition.

This class estimates the meta model \metaModel: \Rset^\inputDim \rightarrow \Rset^\outputDim defined by:

(1)\metaModel(\vect{x})  =  \vect{c} + \Tr{\mat{L}}(\vect{x} - \vect{b})

from an experimental design \cX of size \sampleSize, that is, a set of observations of the input vector defined by:

(2)\cX = \left\{ \vect{x}^{(1)}, \dots, \vect{x}^{(\sampleSize)} \right\},

and the corresponding output vectors:

(3)\cY = \left\{ \vect{y}^{(1)}, \dots, \vect{y}^{(\sampleSize)} \right\}.

where \vect{y}^{(k)} = \model{ \vect{x}^{(k)}}.

Refer to Least squares meta models to get details on general least squares meta models and to get information on the estimation of the matrix \mat{M} \in \cM_{\inputDim, \outputDim}, the center vector \vect{b}\in \Rset^\inputDim and the constant vector \vect{c} \in \Rset^\outputDim.

Examples

>>> import openturns as ot
>>> formulas = ['cos(x1 + x2)', '(x2 + 1) * exp(x1 - 2 * x2)']
>>> f = ot.SymbolicFunction(['x1', 'x2'], formulas)
>>> X  = [[0.5,0.5], [-0.5,-0.5], [-0.5,0.5], [0.5,-0.5]]
>>> X += [[0.25,0.25], [-0.25,-0.25], [-0.25,0.25], [0.25,-0.25]]
>>> Y = f(X)
>>> algo = ot.LinearLeastSquares(X, Y)
>>> algo.run()
>>> mm = algo.getResult().getMetaModel()
>>> x = [0.1, 0.1]
>>> y = mm(x)
__init__(*args)
getCenter()

Get the centering vector of the approximation.

Returns:
centerVectorPoint

Centering vector of the approximation, equal to c.

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

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

getConstant()

Get the constant vector of the approximation.

Returns:
constantVectorPoint

Constant vector \vect{c}.

Notes

The constant vector \vect{c} is defined in (1).

getInputSample()

Get the input data.

Returns:
dataInSample

Input data.

Notes

The input experimental design is defined in (2).

getLinear()

Get the linear matrix of the approximation.

Returns:
linearMatrixMatrix

Linear matrix \mat{L}.

Notes

The linear matrix \mat{L} is defined in (1).

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getOutputSample()

Get the output data.

Returns:
dataOutSample

Output data.

Notes

The output experimental design is defined in (3).

getResult()

Get the meta model result class.

Returns:
resultMetaModelResult

The class that contains all the results on the meta model.

Notes

To get the meta model \metaModel defined in (1) as a Function, use the getMetaModel() method.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

run()

Perform the least squares approximation.

setDataOut(dataOut)

Set the output data.

Parameters:
dataOut2-d sequence of float

Output data.

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

Examples using the class

Calibration without observed inputs

Calibration without observed inputs

Use the Smolyak quadrature

Use the Smolyak quadrature

Create a linear least squares model

Create a linear least squares model

Over-fitting and model selection

Over-fitting and model selection