KrigingAlgorithm¶

class
KrigingAlgorithm
(*args)¶ Kriging algorithm.
Refer to Kriging.
 Available constructors:
KrigingAlgorithm(inputSample, outputSample, covarianceModel, basis, normalize=True)
KrigingAlgorithm(inputSample, outputSample, covarianceModel, basisCollection, normalize=True)
Parameters:  inputSample, outputSample : 2d sequence of float
The samples and upon which the metamodel is built.
 covarianceModel :
CovarianceModel
Covariance model used for the underlying Gaussian process assumption.
 basis :
Basis
Functional basis to estimate the trend (universal kriging): .
If , the same basis is used for each marginal output.
 basisCollection : sequence of
Basis
Collection of functional basis: one basis for each marginal output: . If the sequence is empty, no trend coefficient is estimated (simple kriging).
 normalize : bool, optional
Indicates whether the input sample has to be normalized.
The transformation used is fixed by the User in inputTransformation or the empirical mean and variance of the input sample. Default is set in resource map key GeneralLinearModelAlgorithmNormalizeData
Notes
We suppose we have a sample where for all k, with the model.
The meta model Kriging is based on the same principles as those of the general linear model: it assumes that the sample is considered as the trace of a Gaussian process on . The Gaussian process is defined by:
(1)¶
where:
with and the trend functions.
is a Gaussian process of dimension p with zero mean and covariance function (see
CovarianceModel
for the notations).The estimation of the parameters are made by the
GeneralLinearModelAlgorithm
class.The Kriging algorithm makes the general linear model interpolary on the input samples. The Kriging meta model is defined by:
where is the condition for each .
(1) writes:
where is a matrix in and .
A known centered gaussian observation noise can be taken into account with
setNoise()
:Examples
Create the model and the samples:
>>> import openturns as ot >>> # use of Hmat implementation >>> # ot.ResourceMap.Set('KrigingAlgorithmLinearAlgebra', 'HMAT') >>> f = ot.SymbolicFunction(['x'], ['x * sin(x)']) >>> inputSample = ot.Sample([[1.0], [3.0], [5.0], [6.0], [7.0], [8.0]]) >>> outputSample = f(inputSample)
Create the algorithm:
>>> basis = ot.ConstantBasisFactory().build() >>> covarianceModel = ot.SquaredExponential(1) >>> algo = ot.KrigingAlgorithm(inputSample, outputSample, covarianceModel, basis) >>> algo.run()
Get the resulting meta model:
>>> result = algo.getResult() >>> metamodel = result.getMetaModel()
Methods
getClassName
()Accessor to the object’s name. getDistribution
()Accessor to the joint probability density function of the physical input vector. getId
()Accessor to the object’s id. getInputSample
()Accessor to the input sample. getName
()Accessor to the object’s name. getNoise
()Observation noise variance accessor. getOptimizationAlgorithm
()Accessor to solver used to optimize the covariance model parameters. getOptimizationBounds
()Accessor to the optimization bounds. getOptimizeParameters
()Accessor to the covariance model parameters optimization flag. getOutputSample
()Accessor to the output sample. getReducedLogLikelihoodFunction
()Accessor to the reduced loglikelihood function that writes as argument of the covariance’s model parameters. getResult
()Get the results of the metamodel computation. getShadowedId
()Accessor to the object’s shadowed id. getVisibility
()Accessor to the object’s visibility state. hasName
()Test if the object is named. hasVisibleName
()Test if the object has a distinguishable name. run
()Compute the response surface. setDistribution
(distribution)Accessor to the joint probability density function of the physical input vector. setName
(name)Accessor to the object’s name. setNoise
(noise)Observation noise variance accessor. setOptimizationAlgorithm
(solver)Accessor to the solver used to optimize the covariance model parameters. setOptimizationBounds
(optimizationBounds)Accessor to the optimization bounds. setOptimizeParameters
(optimizeParameters)Accessor to the covariance model parameters optimization flag. setShadowedId
(id)Accessor to the object’s shadowed id. setVisibility
(visible)Accessor to the object’s visibility state. 
__init__
(*args)¶ Initialize self. See help(type(self)) for accurate signature.

getClassName
()¶ Accessor to the object’s name.
Returns:  class_name : str
The object class name (object.__class__.__name__).

getDistribution
()¶ Accessor to the joint probability density function of the physical input vector.
Returns:  distribution :
Distribution
Joint probability density function of the physical input vector.
 distribution :

getId
()¶ Accessor to the object’s id.
Returns:  id : int
Internal unique identifier.

getName
()¶ Accessor to the object’s name.
Returns:  name : str
The name of the object.

getNoise
()¶ Observation noise variance accessor.
Returns:  noise : sequence of positive float
The noise variance of each output value.

getOptimizationAlgorithm
()¶ Accessor to solver used to optimize the covariance model parameters.
Returns:  algorithm :
OptimizationAlgorithm
Solver used to optimize the covariance model parameters.
 algorithm :

getOptimizationBounds
()¶ Accessor to the optimization bounds.
Returns:  problem :
Interval
The bounds used for numerical optimization of the likelihood.
 problem :

getOptimizeParameters
()¶ Accessor to the covariance model parameters optimization flag.
Returns:  optimizeParameters : bool
Whether to optimize the covariance model parameters.

getOutputSample
()¶ Accessor to the output sample.
Returns:  outputSample :
Sample
The output sample .
 outputSample :

getReducedLogLikelihoodFunction
()¶ Accessor to the reduced loglikelihood function that writes as argument of the covariance’s model parameters.
Returns:  reducedLogLikelihood :
Function
The reduced loglikelihood function as a function of .
Notes
The reduced loglikelihood function may be useful for some pre/postprocessing: vizuaisation of the maximizer, use of an external optimizers to maximize the reduced loglikelihood etc.
Examples
Create the model and the samples:
>>> import openturns as ot >>> f = ot.SymbolicFunction(['x0'], ['x0 * sin(x0)']) >>> inputSample = ot.Sample([[1.0], [3.0], [5.0], [6.0], [7.0], [8.0]]) >>> outputSample = f(inputSample)
Create the algorithm:
>>> basis = ot.ConstantBasisFactory().build() >>> covarianceModel = ot.SquaredExponential(1) >>> algo = ot.KrigingAlgorithm(inputSample, outputSample, covarianceModel, basis) >>> algo.run()
Get the reduced loglikelihood function:
>>> reducedLogLikelihoodFunction = algo.getReducedLogLikelihoodFunction()
 reducedLogLikelihood :

getResult
()¶ Get the results of the metamodel computation.
Returns:  result :
KrigingResult
Structure containing all the results obtained after computation and created by the method
run()
.
 result :

getShadowedId
()¶ Accessor to the object’s shadowed id.
Returns:  id : int
Internal unique identifier.

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.

run
()¶ Compute the response surface.
Notes
It computes the kriging response surface and creates a
KrigingResult
structure containing all the results.

setDistribution
(distribution)¶ Accessor to the joint probability density function of the physical input vector.
Parameters:  distribution :
Distribution
Joint probability density function of the physical input vector.
 distribution :

setName
(name)¶ Accessor to the object’s name.
Parameters:  name : str
The name of the object.

setNoise
(noise)¶ Observation noise variance accessor.
Parameters:  noise : sequence of positive float
The noise variance of each output value.

setOptimizationAlgorithm
(solver)¶ Accessor to the solver used to optimize the covariance model parameters.
Parameters:  algorithm :
OptimizationAlgorithm
Solver used to optimize the covariance model parameters.
Examples
Create the model and the samples:
>>> import openturns as ot >>> input_data = ot.Uniform(1.0, 2.0).getSample(10) >>> model = ot.SymbolicFunction(['x'], ['x1+sin(pi_*x/(1+0.25*x^2))']) >>> output_data = model(input_data)
Create the Kriging algorithm with the optimizer option:
>>> basis = ot.Basis([ot.SymbolicFunction(['x'], ['0.0'])]) >>> thetaInit = 1.0 >>> covariance = ot.GeneralizedExponential([thetaInit], 2.0) >>> bounds = ot.Interval(1e2,1e2) >>> algo = ot.KrigingAlgorithm(input_data, output_data, covariance, basis) >>> algo.setOptimizationBounds(bounds)
 algorithm :

setOptimizationBounds
(optimizationBounds)¶ Accessor to the optimization bounds.
Parameters:  bounds :
Interval
The bounds used for numerical optimization of the likelihood.
Notes
See
GeneralLinearModelAlgorithm
class for more details, particularlysetOptimizationBounds()
. bounds :

setOptimizeParameters
(optimizeParameters)¶ Accessor to the covariance model parameters optimization flag.
Parameters:  optimizeParameters : bool
Whether to optimize the covariance model parameters.

setShadowedId
(id)¶ Accessor to the object’s shadowed id.
Parameters:  id : int
Internal unique identifier.

setVisibility
(visible)¶ Accessor to the object’s visibility state.
Parameters:  visible : bool
Visibility flag.