Load saved model

Hi there,

First of all, thank you so much for this tool, is amazing. As I mentioned in a previous topic, I developed a PCE model and the results are very good. I saved the model using save(filename, myPCE) and ended my MatLab session.

Now I open again MatLab and loaded the mat file. I am able to evaluate the model (i.e., uq_evalModel(myPCE, X)) but when I try to perform a sensitivity analysis, the model is not recognized (e.g., uq_createAnalysis(SobolSensOpts);).

I tried with uq_selectModel(myPCE) or uq_getModel(myPCE) but both of them print an error.

Do you know how can I load my PCE model? I don’t want to run the analysis again.

Thanks in advance

Well, I think I found a way to “load” my model, however if there is a more elegant method I would appreciate if you could tell me.

% Create input
InputOpts.Marginals(1).Name = 'alpha1';
InputOpts.Marginals(1).Type = 'Uniform';
InputOpts.Marginals(1).Parameters = [0.5 1.5];
myInput = uq_createInput(InputOpts);

% Create model from file
n = 2002;
lambda1_SBFO = zeros(6,n);
lambda1_SBTO = zeros(6,n);

for i=1:n
    clear ModelOpts
    ModelOpts.Type = 'Metamodel';
    ModelOpts.MetaType = 'PCE';
    ModelOpts.Method = 'custom'
    ModelOpts.Degree = 14;
    ModelOpts.PCE = uq_copy_structure(myPCE_LARS.PCE(i));
    ModelOpts.Basis = uq_copy_structure(myPCE_LARS.PCE(i).Basis);
    ModelOpts.Coefficients = myPCE_LARS.PCE(i).Coefficients;
    ModelOpts.Input = myInput;
    myModel = uq_createModel(ModelOpts);

    SobolSensOpts.Type = 'Sensitivity';
    SobolSensOpts.Method = 'Sobol';
    SobolSensOpts.Sobol.Order = 2;
    SobolAnalysis(i) = uq_createAnalysis(SobolSensOpts);

    lambda1_SBFO(:,i) = SobolAnalysis(i).Results.FirstOrder;
    lambda1_SBTO(:,i) = SobolAnalysis(i).Results.Total;

Hi @sebacastroh,

Did you by any chance try also this:

SobolSensOpts.Model = myPCE;  % load from your saved PCE
SobolSensOpts.Input = myPCE.Internal.Input;

The second line is actually not necessary for computing the indices from PCE coefficients because all the information required is contained in myPCE, but calling uq_createAnalysis for Sobol’ sensitivity analysis somehow requires an INPUT object to be defined. We’ll check if this is really necessary in this case, but I think the above should work for your case.

Let me know if it works (or not…)!

Yes, it worked. Thanks!