TensorizedCovarianceModel¶
(Source code, svg)
- class TensorizedCovarianceModel(*args)¶
- Multivariate covariance function defined as a tensorization of covariance models. - Parameters:
- collsequence of CovarianceModel
- Collection of covariance models - of dimension - . 
 
- collsequence of 
 - Methods - activateAmplitude(isAmplitudeActive)- Activate/deactivate the amplitude parameter(s). - activateNuggetFactor(isNuggetFactorActive)- Activate/deactivate the nugget factor. - activateScale(isScaleActive)- Activate/deactivate the scale parameter(s). - computeAsScalar(*args)- Compute the covariance function for scalar model. - computeCrossCovariance(*args)- Compute the covariance function on a given mesh. - discretize(*args)- Discretize the covariance function on a given mesh. - discretizeAndFactorize(*args)- Discretize and factorize the covariance function on a given mesh. - Discretize and factorize the covariance function on a given mesh. - discretizeHMatrix(*args)- Discretize the covariance function on a given mesh using HMatrix result. - discretizeRow(vertices, p)- (TODO) - draw(*args)- Draw a specific component of the covariance model with input dimension 1. - Accessor to the active parameter set. - Get the amplitude parameter - of the covariance function. - Accessor to the object's name. - Covariance model collection accessor. - Get the full parameters of the covariance function. - Get the description full parameters of the covariance function. - Get the input dimension - of the covariance function. - getMarginal(index)- Get the ith marginal of the model. - getName()- Accessor to the object's name. - Accessor to the nugget factor. - Get the spatial correlation matrix - of the covariance function. - Get the dimension - of the covariance function. - Get the parameters of the covariance function. - Get the description of the covariance function parameters. - getScale()- Get the scale parameter - of the covariance function. - hasName()- Test if the object is named. - Test whether the model is diagonal or not. - Accessor to the parallel flag. - Test whether the model is stationary or not. - parameterGradient(s, t)- Compute the gradient according to the parameters. - partialGradient(s, t)- Compute the gradient of the covariance function. - setActiveParameter(active)- Accessor to the active parameter set. - setAmplitude(amplitude)- Set the amplitude parameter - of the covariance function. - setFullParameter(parameter)- Set the full parameters of the covariance function. - setName(name)- Accessor to the object's name. - setNuggetFactor(nuggetFactor)- Set the nugget factor for the variance of the observation error. - setOutputCorrelation(correlation)- Set the spatial correlation matrix - of the covariance function. - setParameter(parameter)- Set the parameters of the covariance function. - setScale(scale)- Set the scale parameter - of the covariance function. - Notes - The tensorized covariance model defines a multivariate covariance model of dimension - from the tensorization of a given collection of covariance models. This allows one to create a higher dimension covariance model by combining models of smaller dimensions. The dimension of each model in the collection does not necessarily have to be equal to 1. The input dimension of each covariance model in the collection must be the same. - We consider the stochastic process - , where - is an event, - is a domain of - . - Its covariance function - is defined from the collection of covariance functions - where - , as follows: - The amplitude of the covariance function is - and each model - is parameterized by its scale - . - The method - updates the scale the following way. Let - be the initial scale of the covariance model - . After the update, - has the scale - where - . - Examples - Create a tensorized covariance function from the tensorization of an absolute exponential function, a squared exponential function and an exponential function: - >>> import openturns as ot >>> inputDimension = 2 - Create the each covariance models: - >>> myCov1 = ot.AbsoluteExponential([3.0] * inputDimension) >>> myCov2 = ot.SquaredExponential([2.0] * inputDimension) - Define the scale of the tensorized model: - >>> scale = [0.3, 0.8] - Create the tensorized model: - >>> covarianceModel = ot.TensorizedCovarianceModel([myCov1, myCov2], scale) - Fix the same scale to each model: - >>> covarianceModel.setScale([1.0] * inputDimension) - __init__(*args)¶
 - activateAmplitude(isAmplitudeActive)¶
- Activate/deactivate the amplitude parameter(s). - In the context of Kriging, defines whether amplitude parameters should be tuned. - Parameters:
- isAmplitudeActivebool
- If True, the amplitude parameters are all tuned. If False, none of them is tuned. 
 
 
 - activateNuggetFactor(isNuggetFactorActive)¶
- Activate/deactivate the nugget factor. - In the context of Kriging, defines whether the nugget factor should be tuned. - Parameters:
- isNuggetFactorActivebool
- If True (resp. False), the nugget factor is (resp. is not) tuned. 
 
 
 - activateScale(isScaleActive)¶
- Activate/deactivate the scale parameter(s). - In the context of Kriging, defines whether scale parameters should be tuned. - Parameters:
- isScaleActivebool
- If True, the scale parameters are all tuned. If False, none of them is tuned. 
 
 
 - computeAsScalar(*args)¶
- Compute the covariance function for scalar model. - Available usages:
- computeAsScalar(s, t) - computeAsScalar(tau) 
 - Parameters:
- s, tfloats (if ) or sequences of floats (any ) 
- Multivariate index 
- taufloat (if ) or sequence of floats (any ) 
- Multivariate index 
 
- s, tfloats (if 
- Returns:
- covariancefloat
- Covariance. 
 
 - Notes - The method makes sense only if the dimension of the process is - . It evaluates - . - In the second usage, the covariance model must be stationary. Then we note - for - as this quantity does not depend on - . 
 - computeCrossCovariance(*args)¶
- Compute the covariance function on a given mesh. - Parameters:
- Returns:
- MatrixMatrix
- Cross covariance matrix 
 
- Matrix
 - Notes - This method computes a cross-covariance matrix. The cross-covariance is the evaluation of the covariance model on both firstVertices and secondVertices. - If firstVertices contains - points and secondVertices contains - points, the method returns an - matrix ( - being the output dimension). - To make things easier, let us focus on the - case. Let - be the points of firstVertices and let - be the points of secondVertices. The result is the - matrix - such that for any nonnegative integers - and - , - . 
 - discretize(*args)¶
- Discretize the covariance function on a given mesh. - Parameters:
- whereMeshorRegularGridorSample
- Container of the discretization vertices 
 
- where
- Returns:
- covarianceMatrixCovarianceMatrix
- Covariance matrix - (if the process is of dimension - ) 
 
- covarianceMatrix
 - Notes - This method makes a discretization of the model on the given - Mesh,- RegularGridor- Samplecomposed of the vertices- and returns the covariance matrix: 
 - discretizeAndFactorize(*args)¶
- Discretize and factorize the covariance function on a given mesh. - Parameters:
- whereMeshorRegularGridorSample
- Container of the discretization vertices 
 
- where
- Returns:
- CholeskyMatrixTriangularMatrix
- Cholesky factor of the covariance matrix - (if the process is of dimension - ) 
 
- CholeskyMatrix
 - Notes - This method makes a discretization of the model on the given - Mesh,- RegularGridor- Samplecomposed of the vertices- thanks to the - discretize()method and returns its Cholesky factor.
 - discretizeAndFactorizeHMatrix(*args)¶
- Discretize and factorize the covariance function on a given mesh. - This uses HMatrix. - Parameters:
- whereMeshorRegularGridorSample
- Container of the discretization vertices 
- hmatParamHMatrixParameters
- Parameter values for the HMatrix 
 
- where
- Returns:
- HMatrixHMatrix
- Cholesk matrix - (if the process is of dimension - ), stored in hierarchical format (H-Matrix) 
 
- HMatrix
 - Notes - This method is similar to the - discretizeAndFactorize()method. This method requires that requires that OpenTURNS has been compiled with the hmat library. The method is helpful for very large parameters (Mesh, grid, Sample) because it compresses data.
 - discretizeHMatrix(*args)¶
- Discretize the covariance function on a given mesh using HMatrix result. - Parameters:
- whereMeshorRegularGridorSample
- Container of the discretization vertices 
- hmatParamHMatrixParameters
- Parameter values for the HMatrix 
 
- where
- Returns:
- HMatrixHMatrix
- Covariance matrix - (if the process is of dimension - ), stored in hierarchical format (H-Matrix) 
 
- HMatrix
 - Notes - This method is similar to the - discretize()method. This method requires that OpenTURNS has been compiled with the hmat library. The method is helpful for very large parameters (Mesh, grid, Sample) because it compresses data.
 - discretizeRow(vertices, p)¶
- (TODO) 
 - draw(*args)¶
- Draw a specific component of the covariance model with input dimension 1. - Parameters:
- rowIndexint, 
- The row index of the component to draw. Default value is 0. 
- columnIndex: int, :math:`0 leq columnIndex < dimension`
- The column index of the component to draw. Default value is 0. 
- tMinfloat
- The lower bound of the range over which the model is plotted. Default value is CovarianceModel-DefaultTMin in - ResourceMap.
- tMaxfloat
- The upper bound of the range over which the model is plotted. Default value is CovarianceModel-DefaultTMax in - ResourceMap.
- pointNumberint, 
- The discretization of the range - over which the model is plotted. Default value is CovarianceModel-DefaultPointNumber in class:~openturns.ResourceMap. 
- asStationarybool
- Flag to tell if the model has to be plotted as a stationary model, ie as a function of the lag - if equals to True, or as a non-stationary model, ie as a function of - if equals to False. Default value is True. 
- correlationFlagbool
- Flag to tell if the model has to be plotted as a correlation function if equals to True or as a covariance function if equals to False. Default value is False. 
 
- rowIndexint, 
- Returns:
- graphGraph
- A graph containing a unique curve if asStationary=True and if the model is actually a stationary model, or containing the iso-values of the model if asStationary=False or if the model is nonstationary. 
 
- graph
 
 - getActiveParameter()¶
- Accessor to the active parameter set. - In the context of kriging, it allows one to choose which hyperparameters are tuned. - Returns:
- activeIndices
- Indices of the active parameters. 
 
- active
 
 - getAmplitude()¶
- Get the amplitude parameter - of the covariance function. - Returns:
- amplitudePoint
- The amplitude parameter - of the covariance function. 
 
- amplitude
 
 - getClassName()¶
- Accessor to the object’s name. - Returns:
- class_namestr
- The object class name (object.__class__.__name__). 
 
 
 - getCollection()¶
- Covariance model collection accessor. - Returns:
- collsequence of CovarianceModel
- Collection of covariance models - of dimension - . 
 
- collsequence of 
 
 - getFullParameter()¶
- Get the full parameters of the covariance function. - Returns:
- parameterPoint
- List the full parameter of the covariance function i.e. scale parameter - , the the amplitude parameter - , the Spatial correlation parameter - ; and potential other parameter depending on the model; 
 
- parameter
 
 - getFullParameterDescription()¶
- Get the description full parameters of the covariance function. - Returns:
- descriptionDescription
- Description of the full parameter of the covariance function. 
 
- description
 
 - getInputDimension()¶
- Get the input dimension - of the covariance function. - Returns:
- inputDimensionint
- Spatial dimension - of the covariance function. 
 
 
 - getMarginal(index)¶
- Get the ith marginal of the model. - Returns:
- marginalint or sequence of int
- index of marginal of the model. 
 
 
 - getName()¶
- Accessor to the object’s name. - Returns:
- namestr
- The name of the object. 
 
 
 - getNuggetFactor()¶
- Accessor to the nugget factor. - This parameter allows smooth predictions from noisy data. The nugget is added to the diagonal of the assumed training covariance (thanks to discretize) and acts as a Tikhonov regularization in the problem. - Returns:
- nuggetFactorfloat
- Nugget factor used to model the observation error variance. 
 
 
 - getOutputCorrelation()¶
- Get the spatial correlation matrix - of the covariance function. - Returns:
- spatialCorrelationCorrelationMatrix
- Correlation matrix - . 
 
- spatialCorrelation
 
 - getOutputDimension()¶
- Get the dimension - of the covariance function. - Returns:
- dint
- Dimension - such that - This is the dimension of the process - . 
 
 
 - getParameter()¶
- Get the parameters of the covariance function. - Returns:
- parametersPoint
- List of the scale parameter - and the amplitude parameter - of the covariance function. - The other specific parameters are not included. 
 
- parameters
 
 - getParameterDescription()¶
- Get the description of the covariance function parameters. - Returns:
- descriptionParamDescription
- Description of the components of the parameters obtained with the getParameter method.. 
 
- descriptionParam
 
 - getScale()¶
- Get the scale parameter - of the covariance function. - Returns:
- scalePoint
- The scale parameter - used in the covariance function. 
 
- scale
 
 - hasName()¶
- Test if the object is named. - Returns:
- hasNamebool
- True if the name is not empty. 
 
 
 - isDiagonal()¶
- Test whether the model is diagonal or not. - Returns:
- isDiagonalbool
- True if the model is diagonal. 
 
 
 - isParallel()¶
- Accessor to the parallel flag. - Returns:
- isParallelbool
- Whether the object is considered thread-safe. 
 
 
 - isStationary()¶
- Test whether the model is stationary or not. - Returns:
- isStationarybool
- True if the model is stationary. 
 
 - Notes - The covariance function - is stationary when it is invariant by translation: - We note - for - . 
 - parameterGradient(s, t)¶
- Compute the gradient according to the parameters. - Parameters:
- s, tsequences of float
- Multivariate index - . 
 
- Returns:
- gradientMatrix
- Gradient of the function according to the parameters. 
 
- gradient
 
 - partialGradient(s, t)¶
- Compute the gradient of the covariance function. - Parameters:
- s, tfloats or sequences of float
- Multivariate index - . 
 
- Returns:
- gradientMatrix
- Gradient of the covariance function. 
 
- gradient
 
 - setActiveParameter(active)¶
- Accessor to the active parameter set. - This method defines which hyperparameters are tuned. - Parameters:
- activesequence of int
- Indices of the active parameters. 
 
 - Notes - In order to get the position of a parameter known by its name, we have to first call the method - getFullParameterDescription()and then call the method find as shown in the following example.- Examples - For example, we create a - MaternModelcovariance model. By default, only the scale and the amplitude parameters are active and will be estimated. We want to add the estimation of the- parameter. - >>> import openturns as ot >>> covModel = ot.MaternModel() - We get the default active parameters description: we can see that the - parameter is not included in the list. - >>> covModel.getParameterDescription() [scale_0,amplitude_0] - We now get the active parameters. The parameter - is not in the list. - >>> active = covModel.getActiveParameter() >>> print(active) [0,2] - We want to search the index associated to the parameter - in the full list of the parameters indices. - >>> activeDesc = covModel.getFullParameterDescription() >>> print(activeDesc) [scale_0,nuggetFactor,amplitude_0,nu] >>> index = activeDesc.find('nu') >>> print(index) 3 - Now, we add the index of - in the initial list of active parameters. We sort the active indices by increasing order. Then we update the list of the active parameters. - >>> active = covModel.getActiveParameter() >>> active.add(index) >>> covModel.setActiveParameter(sorted(active)) - Check that the parameter - is in the active parameters list! - >>> covModel.getActiveParameter() [0,2,3] - >>> covModel.getFullParameterDescription() [scale_0,nuggetFactor,amplitude_0,nu] 
 - setAmplitude(amplitude)¶
- Set the amplitude parameter - of the covariance function. - Parameters:
- amplitudePoint
- The amplitude parameter - to be used in the covariance function. Its size must be equal to the dimension of the covariance function. 
 
- amplitude
 
 - setFullParameter(parameter)¶
- Set the full parameters of the covariance function. - Parameters:
- parameterPoint
- List the full parameter of the covariance function i.e. scale parameter - , the the amplitude parameter - , the Spatial correlation parameter - ; and potential other parameter depending on the model; - Must be at least of dimension - . 
 
- parameter
 
 - setName(name)¶
- Accessor to the object’s name. - Parameters:
- namestr
- The name of the object. 
 
 
 - setNuggetFactor(nuggetFactor)¶
- Set the nugget factor for the variance of the observation error. - Acts on the discretized covariance matrix. - Parameters:
- nuggetFactorfloat
- nugget factor to be used to model the variance of the observation error. 
 
 
 - setOutputCorrelation(correlation)¶
- Set the spatial correlation matrix - of the covariance function. - Parameters:
- spatialCorrelationCorrelationMatrix
- Correlation matrix - . 
 
- spatialCorrelation
 
 
Examples using the class¶
Example of multi output Gaussian Process Regression on the fire satellite model
 OpenTURNS
      OpenTURNS