[ot-users] gPC generation: seperate training set calculations and generation of the polynomial

François Sanson frcs.sanson at gmail.com
Thu Jan 26 11:57:45 CET 2017


Hi Géraud,
This is really helpful
Thank you
Best regards

Francois

On Wed, Jan 25, 2017 at 2:43 PM, BLATMAN Geraud <geraud.blatman at edf.fr>
wrote:

> Hi François,
>
>
> I begin with your 2nd question. Yes it is possible to train the metamodel
> based only on the input and the output data sets. Indeed, a possible
> usage of ``FunctionalChaosAlgorithm`` is as follows:
>
> FunctionalChaosAlgorithm(*inputSample, outputSample, distribution,
> adaptiveStrategy*)
>
> Note that this usage requires the knowledge of
> the probability distribution (argument ``distribution``) of
> your inputs. You may have a look at the doc
> <http://doc.openturns.org/openturns-1.5/sphinx/user_manual/_generated/openturns.FunctionalChaosAlgorithm.html>
> and adapt the example located at the bottom of the page.
>
>
> This way it is easy to construct a polynomial chaos from a training set
> and to validate it based on a separated validation set. Here are a
> few commands (partially based on the ``numpy`` module) which you may use to
> this purpose:
>
>
> >>> import numpy as np
>
> >>> import openturns as ot
>
> >>> from openturns.viewer import View
>
> >>>
>
> >>> # Import input and output data sets as OT Numerical Samples
>
> >>> inputs = ot.NumericalSample.ImportFromCSVFile("my_inputs.txt")
>
> >>> outputs = ot.NumericalSample.ImportFromCSVFile("my_outputs.txt")
>
> >>>
>
> >>> # Convert them to numpy arrays to allow easy manipulations
>
> >>> inputs_arr, outputs_arr = np.array(inputs), np.array(outputs)
>
> >>>
>
> >>> # Randomly split the data into training and validation sets
>
> >>> np.random.seed(10) # set the random generator seed
>
> >>> n = inputs.getDimension()
>
> >>> fraction_train = 0.7 # proportion of points used for training
>
> >>> n_train = int(n*fraction_train) # number of training points
>
> >>> inds = np.random.permutation(n)
> >>> xs, ys = x[inds,:], y[inds,:]
> >>> x_train, x_valid = xs[:n_train, :], xs[n_train:, :]
> >>> y_train, y_valid = ys[:n_train, :], ys[n_train:, :]
>
> >>>
>
> (... polynomial chaos command lines ...)
>
> >>> algo = ot.FunctionalChaosAlgorithm(x_train, y_train, distribution,
> fixedStrategy, self.projectionStrategy)
>
> >>> algo.run()
>
> >>> result = algo.getResult()
>
> >>>
>
> >>> # Validate the metamodel
>
> >>> valid = ot.MetaModelValidation(x_train, y_train,
> result.getMetaModel())
> >>> self.relative_accuracy = valid.computePredictivityFactor()
> >>> graph = valid.drawValidation()
>
> >>> View(graph)
>
>
> Regards,
>
>
> Géraud
>
>
> ------------------------------
> *De :* users-bounces at openturns.org <users-bounces at openturns.org>
> *Envoyé :* mercredi 25 janvier 2017 11:08
> *À :* users at openturns.org
> *Objet :* [ot-users] gPC generation: seperate training set calculations
> and generation of the polynomial
>
> Hello everyone,
> I am new to OT and I would like to make a polynomial approximation of an
> expensive function. For that I would like first to evaluate the function at
> the colocation points and then train my polynomial.
> In the example in OT, those two steps are not separated. However is there
> a way to run them separately ?
> Alternatively, assuming I already have the training set (colocation points
> and the corresponding function value) is it possible to train the
> polynomial with OT winthout having OT to evaluate the expensive function
> (with the function FunctionalChaosAlgorithm.run()) ?
>
> Thanks a lot
>
> Francois Sanson
>
>
> Ce message et toutes les pièces jointes (ci-après le 'Message') sont
> établis à l'intention exclusive des destinataires et les informations qui y
> figurent sont strictement confidentielles. Toute utilisation de ce Message
> non conforme à sa destination, toute diffusion ou toute publication totale
> ou partielle, est interdite sauf autorisation expresse.
>
> Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de
> le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou
> partie. Si vous avez reçu ce Message par erreur, merci de le supprimer de
> votre système, ainsi que toutes ses copies, et de n'en garder aucune trace
> sur quelque support que ce soit. Nous vous remercions également d'en
> avertir immédiatement l'expéditeur par retour du message.
>
> Il est impossible de garantir que les communications par messagerie
> électronique arrivent en temps utile, sont sécurisées ou dénuées de toute
> erreur ou virus.
> ____________________________________________________
>
> This message and any attachments (the 'Message') are intended solely for
> the addressees. The information contained in this Message is confidential.
> Any use of information contained in this Message not in accord with its
> purpose, any dissemination or disclosure, either whole or partial, is
> prohibited except formal approval.
>
> If you are not the addressee, you may not copy, forward, disclose or use
> any part of it. If you have received this message in error, please delete
> it and all copies from your system and notify the sender immediately by
> return message.
>
> E-mail communication cannot be guaranteed to be timely secure, error or
> virus-free.
>
> _______________________________________________
> OpenTURNS users mailing list
> users at openturns.org
> http://openturns.org/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://openturns.org/pipermail/users/attachments/20170126/78351147/attachment.html>


More information about the users mailing list