forked from openturns/openturns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
125 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ Post-processing | |
:template: class.rst_t | ||
|
||
LinearModelAnalysis | ||
LinearModelValidation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
%feature("docstring") OT::FunctionalChaosValidation | ||
"Validate a functional chaos metamodel. | ||
|
||
Available constructors: | ||
FunctionalChaosValidation(*functionalChaosResult*) | ||
|
||
Parameters | ||
---------- | ||
result : :class:`~openturns.FunctionalChaosResult` | ||
A functional chaos result resulting from a polynomial chaos expansion. | ||
|
||
See also | ||
-------- | ||
FunctionalChaosAlgorithm, FunctionalChaosResult | ||
|
||
Notes | ||
----- | ||
A `FunctionalChaosValidation` object is used for the validation of a functional chaos expansion. | ||
This can be done only if the coefficients of the expansion are estimated | ||
using least squares regression: if the expansion is computed from integration, | ||
then an exception is produced. | ||
|
||
Examples | ||
-------- | ||
Create a polynomial chaos for the Ishigami function: | ||
|
||
>>> import openturns as ot | ||
>>> from math import pi | ||
>>> from openturns.usecases import ishigami_function | ||
>>> im = ishigami_function.IshigamiModel() | ||
>>> distributionList = [ot.Uniform(-pi, pi)] * 3 | ||
>>> distribution = ot.ComposedDistribution(distributionList) | ||
>>> N = 500 | ||
>>> inputTrain = im.distributionX.getSample(N) | ||
>>> outputTrain = im.model(inputTrain) | ||
>>> multivariateBasis = ot.OrthogonalProductPolynomialFactory([im.X1, im.X2, im.X3]) | ||
>>> selectionAlgorithm = ot.LeastSquaresMetaModelSelectionFactory() | ||
>>> projectionStrategy = ot.LeastSquaresStrategy( | ||
>>> inputTrain, outputTrain, selectionAlgorithm | ||
>>> ) | ||
>>> totalDegree = 8 | ||
>>> enumerateFunction = multivariateBasis.getEnumerateFunction() | ||
>>> basisSize = enumerateFunction.getStrataCumulatedCardinal(totalDegree) | ||
>>> adaptiveStrategy = ot.FixedStrategy(multivariateBasis, basisSize) | ||
>>> chaosalgo = ot.FunctionalChaosAlgorithm( | ||
>>> inputTrain, outputTrain, im.distributionX, adaptiveStrategy, projectionStrategy | ||
>>> ) | ||
>>> chaosalgo.run() | ||
>>> result = chaosalgo.getResult() | ||
|
||
Validate the polynomial chaos expansion. | ||
|
||
>>> validation = ot.FunctionalChaosValidation(result, ot.FunctionalChaosValidation.LEAVEONEOUT) | ||
>>> r2Score = validation.computeR2Score() | ||
>>> print('R2 = ', r2Score[0]) | ||
R2 = 0.8... | ||
|
||
>>> # Draw the validation graph | ||
>>> graph = validation.drawValidation()" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
%feature("docstring") OT::LinearModelValidation | ||
"Validate a linear regression metamodel. | ||
|
||
Available constructors: | ||
LinearModelValidation(*linearModelResult*) | ||
|
||
Parameters | ||
---------- | ||
result : :class:`~openturns.LinearModelResult` | ||
A linear model result resulting from linear least squares regression. | ||
|
||
See also | ||
-------- | ||
LinearModelResult | ||
|
||
Notes | ||
----- | ||
A `LinearModelValidation` object is used for the validation of a linear model. | ||
|
||
Examples | ||
-------- | ||
Create a linear model. | ||
|
||
>>> import openturns as ot | ||
>>> distribution = ot.Normal() | ||
>>> func = ot.SymbolicFunction(['x1','x2', 'x3'], ['x1 + x2 + sin(x2 * 2 * pi_) / 5 + 1e-3 * x3^2']) | ||
>>> dimension = 3 | ||
>>> distribution = ot.ComposedDistribution([ot.Normal()] * dimension) | ||
>>> input_sample = distribution.getSample(20) | ||
>>> output_sample = func(input_sample) | ||
>>> algo = ot.LinearModelAlgorithm(input_sample, output_sample) | ||
>>> algo.run() | ||
>>> result = algo.getResult() | ||
|
||
Validated the linear model. | ||
|
||
>>> validation = ot.LinearModelValidation(result, ot.LinearModelValidation.LEAVEONEOUT) | ||
>>> r2Score = validation.computeR2Score() | ||
>>> print('R2 = ', r2Score[0]) | ||
R2 = 0.98... | ||
|
||
>>> # Draw the validation graph | ||
>>> graph = validation.drawValidation()" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters