GeneralizedLinearModelResult

class GeneralizedLinearModelResult(*args)

Generalized linear model result.

Available constructors:

GeneralizedLinearModelResult(inputSample, outputSample, metaModel, residuals, relativeErrors, basis, trendCoefficients, covarianceModel)

GeneralizedLinearModelResult(inputSample, outputSample, metaModel, residuals, relativeErrors, basis, trendCoefficients, covarianceModel, covarianceCholeskyFactor, covarianceHMatrix)

Parameters:

inputSample, outputSample : NumericalSample

The samples (\vect{x}_k)_{1 \leq k \leq N} \in \Rset^d and (\vect{y}_k)_{1 \leq k \leq N}\in \Rset^p.

metaModel : NumericalMathFunction

The meta model: \tilde{\cM}: \Rset^d \rightarrow \Rset^p, defined in :eq:’metaModel’.

residuals : NumericalPoint

The residual errors.

relativeErrors : NumericalPoint

The relative errors.

basis : collection of Basis

Collection of the p functional basis: (\varphi_j^l: \Rset^d \rightarrow \Rset)_{1 \leq j \leq n_l} for each l \in [1, p]. Its size should be equal to zero if the trend is not estimated.

trendCoefficients : collection of NumericalPoint

The trend coeffient vectors (\vect{\alpha}^1, \dots, \vect{\alpha}^p).

covarianceModel : CovarianceModel

Covariance function of the normal process with its optimized parameters.

covarianceCholeskyFactor : TriangularMatrix

The Cholesky factor \mat{L} of \mat{C}.

covarianceHMatrix : HMatrix

The hmat implementation of \mat{L}.

Notes

The structure is usually created by the method run() of a GeneralizedLinearModelAlgorithm, and obtained thanks to the getResult() method.

The meta model \tilde{\cM}: \Rset^d \rightarrow \Rset^p is defined by:

(1)\tilde{\cM}(\vect{x}) = \left(
  \begin{array}{l}
    \mu_1(\vect{x}) \\
    \dots  \\
    \mu_p(\vect{x}) 
   \end{array}
 \right)

where \mu_l(\vect{x}) = \sum_{j=1}^{n_l} \alpha_j^l \varphi_j^l(\vect{x}) and \varphi_j^l: \Rset^d \rightarrow \Rset are the trend functions.

If a normalizing transformation T has been used, the meta model is built on the inputs \vect{z}_k = T(\vect{x}_k) and the meta model writes:

(2)\tilde{\cM}(\vect{x}) = \left(
  \begin{array}{l}
    \mu_1\circ T(\vect{x}) \\
    \dots  \\
    \mu_p\circ T(\vect{x}) 
   \end{array}
 \right)

Examples

Create the model \cM: \Rset \mapsto \Rset and the samples:

>>> import openturns as ot
>>> f = ot.NumericalMathFunction(['x'],  ['x * sin(x)'])
>>> sampleX = [[1.0], [2.0], [3.0], [4.0], [5.0], [6.0]]
>>> sampleY = f(sampleX)

Create the algorithm:

>>> basis = ot.Basis([ot.NumericalMathFunction('x', 'x'), ot.NumericalMathFunction('x', 'x^2')])
>>> covarianceModel = ot.GeneralizedExponential([2.0], 2.0)
>>> algo = ot.GeneralizedLinearModelAlgorithm(sampleX, sampleY, covarianceModel, basis)
>>> algo.run()

Get the result:

>>> result = algo.getResult()

Get the meta model:

>>> metaModel = result.getMetaModel()
>>> graph = metaModel.draw(0.0, 7.0)
>>> cloud = ot.Cloud(sampleX, sampleY)
>>> cloud.setPointStyle('fcircle')
>>> graph = ot.Graph()
>>> graph.add(cloud)
>>> graph.add(f.draw(0.0, 7.0))
>>> graph.setColors(['black', 'blue', 'red'])

Methods

getBasisCollection() Accessor to the collection of basis.
getClassName() Accessor to the object’s name.
getCovarianceModel() Accessor to the covariance model.
getId() Accessor to the object’s id.
getMetaModel() Accessor to the metamodel.
getModel() Accessor to the model.
getName() Accessor to the object’s name.
getNoise() Accessor to the normal process.
getRelativeErrors() Accessor to the relative errors.
getResiduals() Accessor to the residuals.
getShadowedId() Accessor to the object’s shadowed id.
getTransformation() Accessor to the normalizing transformation.
getTrendCoefficients() Accessor to the trend coefficients.
getVisibility() Accessor to the object’s visibility state.
hasName() Test if the object is named.
hasVisibleName() Test if the object has a distinguishable name.
setMetaModel(metaModel) Accessor to the metamodel.
setModel(model) Accessor to the model.
setName(name) Accessor to the object’s name.
setRelativeErrors(relativeErrors) Accessor to the relative errors.
setResiduals(residuals) Accessor to the residuals.
setShadowedId(id) Accessor to the object’s shadowed id.
setTransformation(transformation) Set accessor to the normalizing transformation.
setVisibility(visible) Accessor to the object’s visibility state.
__init__(*args)
getBasisCollection()

Accessor to the collection of basis.

Returns:

basisCollection : collection of Basis

Collection of the p function basis: (\varphi_j^l: \Rset^d \rightarrow \Rset)_{1 \leq j \leq n_l} for each l \in [1, p].

Notes

If the trend is not estimated, the collection is empty.

getClassName()

Accessor to the object’s name.

Returns:

class_name : str

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

getCovarianceModel()

Accessor to the covariance model.

Returns:

covModel : CovarianceModel

The covariance model of the Normal process W.

getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getMetaModel()

Accessor to the metamodel.

Returns:

metaModel : NumericalMathFunction

Metamodel.

getModel()

Accessor to the model.

Returns:

model : NumericalMathFunction

Physical model approximated by a metamodel.

getName()

Accessor to the object’s name.

Returns:

name : str

The name of the object.

getNoise()

Accessor to the normal process.

Returns:

process : Process

Returns the normal process W with the optimized parameters.

getRelativeErrors()

Accessor to the relative errors.

Returns:

relativeErrors : NumericalPoint

The relative errors defined as follows for each output of the model: \displaystyle \frac{\sum_{i=1}^N (y_i - \hat{y_i})^2}{N \Var{\vect{Y}}} with \vect{Y} the vector of the N model’s values y_i and \hat{y_i} the metamodel’s values.

getResiduals()

Accessor to the residuals.

Returns:

residuals : NumericalPoint

The residual values defined as follows for each output of the model: \displaystyle \frac{\sqrt{\sum_{i=1}^N (y_i - \hat{y_i})^2}}{N} with y_i the N model’s values and \hat{y_i} the metamodel’s values.

getShadowedId()

Accessor to the object’s shadowed id.

Returns:

id : int

Internal unique identifier.

getTransformation()

Accessor to the normalizing transformation.

Returns:

transformation : NumericalMathFunction

The transformation T that normalizes the input sample.

getTrendCoefficients()

Accessor to the trend coefficients.

Returns:

trendCoef : collection of NumericalPoint

The trend coeffient vectors (\vect{\alpha}^1, \dots, \vect{\alpha}^p).

getVisibility()

Accessor to the object’s visibility state.

Returns:

visible : bool

Visibility flag.

hasName()

Test if the object is named.

Returns:

hasName : bool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:

hasVisibleName : bool

True if the name is not empty and not the default one.

setMetaModel(metaModel)

Accessor to the metamodel.

Parameters:

metaModel : NumericalMathFunction

Metamodel.

setModel(model)

Accessor to the model.

Parameters:

model : NumericalMathFunction

Physical model approximated by a metamodel.

setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.

setRelativeErrors(relativeErrors)

Accessor to the relative errors.

Parameters:

relativeErrors : sequence of float

The relative errors defined as follows for each output of the model: \displaystyle \frac{\sum_{i=1}^N (y_i - \hat{y_i})^2}{N \Var{\vect{Y}}} with \vect{Y} the vector of the N model’s values y_i and \hat{y_i} the metamodel’s values.

setResiduals(residuals)

Accessor to the residuals.

Parameters:

residuals : sequence of float

The residual values defined as follows for each output of the model: \displaystyle \frac{\sqrt{\sum_{i=1}^N (y_i - \hat{y_i})^2}}{N} with y_i the N model’s values and \hat{y_i} the metamodel’s values.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:

id : int

Internal unique identifier.

setTransformation(transformation)

Set accessor to the normalizing transformation.

Parameters:

transformation : NumericalMathFunction

The transformation T that normalizes the input sample.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:

visible : bool

Visibility flag.