最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

openturns - How to compute the analytical leave-one-out cross-validation score of a polynomial chaos decomposition in Python? -

programmeradmin7浏览0评论

I have a function y = g(x1, ..., xd) where x1, ..., xd are the inputs and y is the output of the function g. I have a multidimensional multivariate sample X and the corresponding output sample Y from the function g. I have computed the polynomial chaos expansion of this function. How to estimate the Q2 leave-one-out cross-validation score using an analytical method?

For example, consider the following sample based on the Ishigami function. The next script computes the coefficients of the PCE using a degree 8 polynomial. How to compute the Q2 score without actually performing the leave-one-out validation?

import openturns as ot
import openturns.experimental as otexp
from openturns.usecases import ishigami_function

im = ishigami_function.IshigamiModel()
sampleSize = 500 
inputTrain = im.inputDistribution.getSample(sampleSize)
outputTrain = im.model(inputTrain)
multivariateBasis = ot.OrthogonalProductPolynomialFactory([im.X1, im.X2, im.X3])
selectionAlgorithm = ot.PenalizedLeastSquaresAlgorithmFactory()
projectionStrategy = ot.LeastSquaresStrategy(inputTrain, outputTrain, selectionAlgorithm)
totalDegree = 8
enumerateFunction = multivariateBasis.getEnumerateFunction()
basisSize = enumerateFunction.getBasisSizeFromTotalDegree(totalDegree)
adaptiveStrategy = ot.FixedStrategy(multivariateBasis, basisSize)
chaosalgo = ot.FunctionalChaosAlgorithm(
    inputTrain, outputTrain, im.inputDistribution, adaptiveStrategy, projectionStrategy
)
chaosalgo.run()
result = chaosalgo.getResult()

I have a function y = g(x1, ..., xd) where x1, ..., xd are the inputs and y is the output of the function g. I have a multidimensional multivariate sample X and the corresponding output sample Y from the function g. I have computed the polynomial chaos expansion of this function. How to estimate the Q2 leave-one-out cross-validation score using an analytical method?

For example, consider the following sample based on the Ishigami function. The next script computes the coefficients of the PCE using a degree 8 polynomial. How to compute the Q2 score without actually performing the leave-one-out validation?

import openturns as ot
import openturns.experimental as otexp
from openturns.usecases import ishigami_function

im = ishigami_function.IshigamiModel()
sampleSize = 500 
inputTrain = im.inputDistribution.getSample(sampleSize)
outputTrain = im.model(inputTrain)
multivariateBasis = ot.OrthogonalProductPolynomialFactory([im.X1, im.X2, im.X3])
selectionAlgorithm = ot.PenalizedLeastSquaresAlgorithmFactory()
projectionStrategy = ot.LeastSquaresStrategy(inputTrain, outputTrain, selectionAlgorithm)
totalDegree = 8
enumerateFunction = multivariateBasis.getEnumerateFunction()
basisSize = enumerateFunction.getBasisSizeFromTotalDegree(totalDegree)
adaptiveStrategy = ot.FixedStrategy(multivariateBasis, basisSize)
chaosalgo = ot.FunctionalChaosAlgorithm(
    inputTrain, outputTrain, im.inputDistribution, adaptiveStrategy, projectionStrategy
)
chaosalgo.run()
result = chaosalgo.getResult()
Share Improve this question edited Mar 25 at 16:31 Michael Baudin asked Mar 25 at 15:28 Michael BaudinMichael Baudin 1,15111 silver badges28 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0
splitterLOO = ot.LeaveOneOutSplitter(sampleSize)
validation = otexp.FunctionalChaosValidation(result, splitterLOO)
r2Score = validationputeR2Score()

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论