diff --git a/examples/pollution/test_pollution.py b/examples/pollution/test_pollution.py index 9e9d5652555157771269e845e24b02c6d64e8739..cbb897481121a75c8bb7d604abd6e8e3cbff5036 100644 --- a/examples/pollution/test_pollution.py +++ b/examples/pollution/test_pollution.py @@ -94,7 +94,7 @@ if __name__ == "__main__": # ===================================================== # ====== POLYNOMIAL CHAOS EXPANSION METAMODELS ====== # ===================================================== - MetaModelOpts = MetaModel(Inputs) + MetaModelOpts = MetaModel(Inputs, Model) # Select if you want to preserve the spatial/temporal depencencies # MetaModelOpts.dim_red_method = 'PCA' @@ -114,9 +114,11 @@ if __name__ == "__main__": # 1)OLS: Ordinary Least Square 2)BRR: Bayesian Ridge Regression # 3)LARS: Least angle regression 4)ARD: Bayesian ARD Regression # 5)FastARD: Fast Bayesian ARD Regression - # 6)VBL: Variational Bayesian Learning - # 7)EBL: Emperical Bayesian Learning - MetaModelOpts.pce_reg_method = 'FastARD' + # 6)BCS: Bayesian Compressive Sensing + # 7)OMP: Orthogonal Matching Pursuit + # 8)VBL: Variational Bayesian Learning + # 9)EBL: Emperical Bayesian Learning + MetaModelOpts.pce_reg_method = 'BCS' # Bootstraping # 1) normal 2) fast @@ -127,7 +129,7 @@ if __name__ == "__main__": # The degree with the lowest Leave-One-Out cross-validation (LOO) # error (or the highest score=1-LOO)estimator is chosen as the final # metamodel. pce_deg accepts degree as a scalar or a range. - MetaModelOpts.pce_deg = np.arange(6) + MetaModelOpts.pce_deg = 8 # q-quasi-norm 0<q<1 (default=1) # MetaModelOpts.pce_q_norm = 0.75 @@ -214,7 +216,7 @@ if __name__ == "__main__": # >>>>>>>>>>>>>>>>>>>>>> Build Surrogate <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # Adaptive sparse arbitrary polynomial chaos expansion - PCEModel = MetaModelOpts.create_metamodel(Model) + PCEModel = MetaModelOpts.create_metamodel() # ===================================================== # ========= POST PROCESSING OF METAMODELS =========== @@ -234,7 +236,7 @@ if __name__ == "__main__": # Plot the sobol indices if MetaModelOpts.meta_model_type != 'GPE': - sobol_cell, total_sobol = PostPCE.sobol_indices() + total_sobol = PostPCE.sobol_indices() # Compute and print RMSE error valid_out_dict = dict() diff --git a/examples/pollution/test_valid_pollution.py b/examples/pollution/test_valid_pollution.py index 0d2a32c00b0d111f0f84a705ecbabf3dd87a62df..a19e7b6a0f81b54e17e51f7bcfa5d8adfdd7dde0 100644 --- a/examples/pollution/test_valid_pollution.py +++ b/examples/pollution/test_valid_pollution.py @@ -94,11 +94,11 @@ if __name__ == "__main__": # ===================================================== # ====== POLYNOMIAL CHAOS EXPANSION METAMODELS ====== # ===================================================== - MetaModelOpts = MetaModel(Inputs) + MetaModelOpts = MetaModel(Inputs, Model) # Select if you want to preserve the spatial/temporal depencencies MetaModelOpts.dim_red_method = 'PCA' - # MetaModelOpts.var_pca_threshold = 99.999 + MetaModelOpts.var_pca_threshold = 99.999 # MetaModelOpts.n_pca_components = 5 # Select your metamodel method @@ -114,8 +114,10 @@ if __name__ == "__main__": # 1)OLS: Ordinary Least Square 2)BRR: Bayesian Ridge Regression # 3)LARS: Least angle regression 4)ARD: Bayesian ARD Regression # 5)FastARD: Fast Bayesian ARD Regression - # 6)VBL: Variational Bayesian Learning - # 7)EBL: Emperical Bayesian Learning + # 6)BCS: Bayesian Compressive Sensing + # 7)OMP: Orthogonal Matching Pursuit + # 8)VBL: Variational Bayesian Learning + # 9)EBL: Emperical Bayesian Learning MetaModelOpts.pce_reg_method = 'FastARD' # Bootstraping @@ -152,7 +154,7 @@ if __name__ == "__main__": # >>>>>>>>>>>>>>>>>>>>>> Build Surrogate <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # Adaptive sparse arbitrary polynomial chaos expansion - PCEModel = MetaModelOpts.create_metamodel(Model) + PCEModel = MetaModelOpts.create_metamodel() # Save PCE models with open(f"PCEModel_{Model.name}.pkl", "wb") as output: @@ -263,8 +265,9 @@ if __name__ == "__main__": ValidInputs.Marginals[3].name = "$\\tau$" ValidInputs.Marginals[3].input_data = BayesCalib.posterior_df['$\\tau$'] - MetaModelOpts_valid = MetaModelOpts.copy_meta_model_opts(ValidInputs) - ValidMetaModel = MetaModelOpts_valid.create_metamodel(ValidModel) + MetaModelOpts_valid = MetaModelOpts.copy_meta_model_opts( + ValidInputs, ValidModel) + ValidMetaModel = MetaModelOpts_valid.create_metamodel() # Save PCE models with open(f"PCEModel_{ValidModel.name}.pkl", "wb") as output: