CleaningStrategy

class CleaningStrategy(*args)

Cleaning truncation strategy.

Available constructors:

CleaningStrategy(orthogonalBasis, maximumDimension)

CleaningStrategy(orthogonalBasis, maximumDimension, maximumSize, significanceFactor)

Parameters:
orthogonalBasisOrthogonalBasis

An OrthogonalBasis.

maximumDimensionpositive int

Maximum index of the basis function that can be used by the EnumerateFunction.

maximumSizepositive int, maximumSize \leq maximumDimension

Maximum number of functions used in the meta model. Its default value is the CleaningStrategy-DefaultMaximumSize key of the ResourceMap.

significanceFactorfloat

Parameter used as a threshold factor for selecting the efficient coefficients of the basis. The actual threshold is the product of the significanceFactor with the maximum magnitude of the current coefficients. Its default value is the CleaningStrategy-DefaultSignificanceFactor key of the ResourceMap.

Methods

computeInitialBasis()

Compute initial basis for the approximation.

getBasis()

Accessor to the underlying orthogonal basis.

getClassName()

Accessor to the object's name.

getCurrentVectorIndex()

Accessor to the current vector index.

getMaximumDimension()

Accessor to the maximum dimension of the orthogonal basis.

getMaximumSize()

Accessor to the maximum number of functions used.

getName()

Accessor to the object's name.

getPsi()

Accessor to the selected orthogonal polynomials in the basis.

getSignificanceFactor()

Accessor to the significance factor.

hasName()

Test if the object is named.

involvesModelSelection()

Get the model selection flag.

setMaximumDimension(maximumDimension)

Accessor to the maximum dimension of the orthogonal basis.

setMaximumSize(maximumSize)

Accessor to the maximum number of functions used.

setName(name)

Accessor to the object's name.

setSignificanceFactor(significanceFactor)

Accessor to the significance factor.

updateBasis(alpha_k, residual, relativeError)

Update the basis for the next iteration of approximation.

Notes

The cleaning strategy aims at building a PC expansion containing only a subset of the coefficients of the full expansion. Hence, this strategy can lead to a sparse expansion which can limit the chances of potential surrogate model overfitting.

Let maximumDimension be the number of coefficients in the full expansion and let maximumSize be the maximum number of coefficients defined by the user. On output, at most maximumSize coefficients are selected. Let \epsilon be the value of the significanceFactor. The method proceeds as follows:

  • Generate an initial PC basis made of the maximumSize first functions (according to the adopted EnumerateFunction), or equivalently an initial set of indices \cK = \{0, \ldots, maximumSize - 1\}.

  • Discard from the basis any function \Psi_j associated with an insignificant coefficient a_j, i.e. such that:

|a_j| \leq \epsilon \max_{ k \in \cK, k \neq 0 } |a_k|.

  • Add the next function to the current basis \cK according to the EnumerateFunction used.

  • Reiterate the procedure until the first maximumDimension functions have been considered.

Examples

In the next example, we select, among the maximumDimension = 100 first polynomials of the multivariate basis, those which have the maximumSize = 20 most significant contribution (greatest absolute value of the coefficients), with respect to the significance factor 10^{-4}.

>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> # Define the model
>>> inputDim = 1
>>> model = ot.SymbolicFunction(['x'], ['x*sin(x)'])
>>> # Create the input distribution
>>> distribution = ot.JointDistribution([ot.Uniform()]*inputDim)
>>> # Construction of the multivariate orthonormal basis
>>> polyColl = [0.0]*inputDim
>>> for i in range(distribution.getDimension()):
...     polyColl[i] = ot.StandardDistributionPolynomialFactory(distribution.getMarginal(i))
>>> enumerateFunction = ot.LinearEnumerateFunction(inputDim)
>>> productBasis = ot.OrthogonalProductPolynomialFactory(polyColl, enumerateFunction)
>>> maximumDimension = 100
>>> maximumSize = 20
>>> significanceFactor = 1e-4
>>> adaptiveStrategy = ot.CleaningStrategy(
...     productBasis, maximumDimension, maximumSize, significanceFactor
... )
__init__(*args)
computeInitialBasis()

Compute initial basis for the approximation.

See also

getPsi
getBasis()

Accessor to the underlying orthogonal basis.

Returns:
basisOrthogonalBasis

Orthogonal basis of which the adaptive strategy is based.

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

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

getCurrentVectorIndex()

Accessor to the current vector index.

Returns:
indexint

Current index of the basis term.

getMaximumDimension()

Accessor to the maximum dimension of the orthogonal basis.

Returns:
maximumDimensionint

Maximum dimension of the truncated basis.

getMaximumSize()

Accessor to the maximum number of functions used.

Returns:
maximumSizeint

Maximum number of significant terms of the basis.

See also

setMaximumSize
getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getPsi()

Accessor to the selected orthogonal polynomials in the basis.

The value returned by this method depends on the specific choice of adaptive strategy and the previous calls to the updateBasis() method.

Returns:
polynomialslist of polynomials

Sequence of P polynomials.

Notes

The method computeInitialBasis() must be applied first.

Examples

>>> import openturns as ot
>>> productBasis = ot.OrthogonalProductPolynomialFactory([ot.HermiteFactory()])
>>> adaptiveStrategy = ot.FixedStrategy(productBasis, 3)
>>> adaptiveStrategy.computeInitialBasis()
>>> print(adaptiveStrategy.getPsi())
[1,x0,-0.707107 + 0.707107 * x0^2]
getSignificanceFactor()

Accessor to the significance factor.

Returns:
significanceFactorfloat

Value of the significance factor.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

involvesModelSelection()

Get the model selection flag.

A model selection method can be used to select the coefficients of the decomposition which enable to best predict the output. Model selection can lead to a sparse functional chaos expansion.

Returns:
involvesModelSelectionbool

True if the method involves a model selection method.

setMaximumDimension(maximumDimension)

Accessor to the maximum dimension of the orthogonal basis.

Parameters:
maximumDimensionint

Maximum dimension of the truncated basis.

setMaximumSize(maximumSize)

Accessor to the maximum number of functions used.

Parameters:
maximumSizeint

Maximum number of significant terms of the basis.

See also

getMaximumSize
setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

setSignificanceFactor(significanceFactor)

Accessor to the significance factor.

Parameters:
significanceFactorfloat

Value of the significance factor.

updateBasis(alpha_k, residual, relativeError)

Update the basis for the next iteration of approximation.

In this strategy, the residual and the relativeError input arguments are ignored.

Parameters:
alpha_ksequence of floats

The coefficients of the expansion at this step.

residualfloat

The current value of the residual. Ignored.

relativeErrorfloat

The relative error. Ignored.

Examples

>>> import openturns as ot
>>> dimension = 3
>>> enumerateFunction = ot.LinearEnumerateFunction(dimension)
>>> productBasis = ot.OrthogonalProductPolynomialFactory(
...     [ot.LegendreFactory()] * dimension, enumerateFunction
... )
>>> degree = 6
>>> basisSize = enumerateFunction.getBasisSizeFromTotalDegree(degree)
>>> maximumDimension = 100
>>> maximumSize = 20
>>> significanceFactor = 1e-4
>>> adaptiveStrategy = ot.CleaningStrategy(
...     productBasis, maximumDimension, maximumSize, significanceFactor
... )
>>> adaptiveStrategy.computeInitialBasis()
>>> print(adaptiveStrategy.getCurrentVectorIndex())
20
>>> psi = adaptiveStrategy.getPsi()
>>> print(len(psi))
20
>>> alpha_k = [3.5, 0.1, 0.0, -0.2, 0.0, 0.3, 0.0, -0.4, 0.0, -0.5]
>>> residual = 0.0  # Ignored
>>> relativeError = 0.0  # Ignored
>>> adaptiveStrategy.updateBasis(alpha_k, residual, relativeError)
>>> psi = adaptiveStrategy.getPsi()
>>> print(len(psi))
7

Examples using the class

Advanced polynomial chaos construction

Advanced polynomial chaos construction

Create a sparse chaos by integration

Create a sparse chaos by integration