MetaModelValidation

class MetaModelValidation(*args)

Base class to score a metamodel and perform validations.

Refer to Cross validation assessment of PC models.

Available constructor:

MetaModelValidation(inputValidationSample, outputValidationSample, metaModel)

Parameters
inputValidationSample, outputValidationSample2-d sequence of float

The input and output validation samples, not used during the learning step.

metaModelFunction

Metamodel to validate.

Notes

A MetaModelValidation object is used for the validation process of a metamodel. For that purpose, a dataset independent of the learning step, is used to score the surrogate model. Its main functionalities are :

  • To compute the predictivity factor Q_2

  • To get the residual sample, its non parametric distribution

  • To draw a model vs metamodel validation graph.

Currently only one dimensional output models are available.

Examples

>>> import openturns as ot
>>> from math import pi
>>> dist = ot.Uniform(-pi/2, pi/2)
>>> # Model here is sin(x)
>>> model = ot.SymbolicFunction(['x'], ['sin(x)'])
>>> # We can build several types of models (kriging, pc, ...)
>>> # We use a Taylor developement (order 5) and compare the metamodel with the model
>>> metaModel = ot.SymbolicFunction(['x'], ['x - x^3/6.0 + x^5/120.0'])
>>> x = dist.getSample(10)
>>> y = model(x)
>>> # Validation of the model
>>> val = ot.MetaModelValidation(x, y, metaModel)
>>> # Compute the first indicator : q2
>>> q2 = val.computePredictivityFactor()
>>> # Get the residual
>>> residual = val.getResidualSample()
>>> # Get the histogram of residual
>>> histoResidual = val.getResidualDistribution(False)
>>> # Draw the validation graph
>>> graph = val.drawValidation()

Methods

computePredictivityFactor(self)

Compute the predictivity factor.

drawValidation(self)

Plot a model vs metamodel graph for visual validation.

getClassName(self)

Accessor to the object’s name.

getId(self)

Accessor to the object’s id.

getInputSample(self)

Accessor to the input sample.

getName(self)

Accessor to the object’s name.

getOutputSample(self)

Accessor to the output sample.

getResidualDistribution(self[, smooth])

Compute the non parametric distribution of the residual sample.

getResidualSample(self)

Compute the residual sample.

getShadowedId(self)

Accessor to the object’s shadowed id.

getVisibility(self)

Accessor to the object’s visibility state.

hasName(self)

Test if the object is named.

hasVisibleName(self)

Test if the object has a distinguishable name.

setName(self, name)

Accessor to the object’s name.

setShadowedId(self, id)

Accessor to the object’s shadowed id.

setVisibility(self, visible)

Accessor to the object’s visibility state.

__init__(self, \*args)

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

computePredictivityFactor(self)

Compute the predictivity factor.

Returns
q2float

The predictivity factor

Notes

The predictivity factor Q_2 is given by :

Q_2 = 1 - \frac{\sum_{l=1}^{N} (Y_{l} -\hat{f}(X_l))^2}{Var(Y)}

drawValidation(self)

Plot a model vs metamodel graph for visual validation.

Returns
graphGraph

The visual validation graph.

getClassName(self)

Accessor to the object’s name.

Returns
class_namestr

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

getId(self)

Accessor to the object’s id.

Returns
idint

Internal unique identifier.

getInputSample(self)

Accessor to the input sample.

Returns
inputSampleSample

Input sample of a model evaluated apart.

getName(self)

Accessor to the object’s name.

Returns
namestr

The name of the object.

getOutputSample(self)

Accessor to the output sample.

Returns
outputSampleSample

Output sample of a model evaluated apart.

getResidualDistribution(self, smooth=True)

Compute the non parametric distribution of the residual sample.

Parameters
smoothbool

Tells if distribution is smooth (true) or not. Default argument is true.

Returns
residualDistributionDistribution

The residual distribution.

Notes

The residual distribution is built thanks to KernelSmoothing if smooth argument is true. Otherwise, an histogram distribution is returned, thanks to HistogramFactory.

getResidualSample(self)

Compute the residual sample.

Returns
residualSample

The residual sample.

Notes

The residual sample is given by :

\epsilon_{l} = Y_{l} -\hat{f}(X_l)

getShadowedId(self)

Accessor to the object’s shadowed id.

Returns
idint

Internal unique identifier.

getVisibility(self)

Accessor to the object’s visibility state.

Returns
visiblebool

Visibility flag.

hasName(self)

Test if the object is named.

Returns
hasNamebool

True if the name is not empty.

hasVisibleName(self)

Test if the object has a distinguishable name.

Returns
hasVisibleNamebool

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

setName(self, name)

Accessor to the object’s name.

Parameters
namestr

The name of the object.

setShadowedId(self, id)

Accessor to the object’s shadowed id.

Parameters
idint

Internal unique identifier.

setVisibility(self, visible)

Accessor to the object’s visibility state.

Parameters
visiblebool

Visibility flag.