.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_algorithms/plot_algorithm_regadaptive.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_algorithms_plot_algorithm_regadaptive.py: Algorithm: RegAdaptive ====================== .. GENERATED FROM PYTHON SOURCE LINES 5-14 .. code-block:: default # Windows users have to encapsulate the code into a main function to avoid multiprocessing errors. # def main(): import pygpc import numpy as np from collections import OrderedDict fn_results = 'tmp/regadaptive' # filename of output save_session_format = ".pkl" # file format of saved gpc session ".hdf5" (slow) or ".pkl" (fast) .. GENERATED FROM PYTHON SOURCE LINES 15-17 Loading the model and defining the problem ------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 17-31 .. code-block:: default # define model model = pygpc.testfunctions.Ishigami() # define problem parameters = OrderedDict() parameters["x1"] = pygpc.Beta(pdf_shape=[1, 1], pdf_limits=[-np.pi, np.pi]) parameters["x2"] = pygpc.Beta(pdf_shape=[1, 1], pdf_limits=[-np.pi, np.pi]) parameters["x3"] = 0. parameters["a"] = 7. parameters["b"] = 0.1 problem = pygpc.Problem(model, parameters) .. GENERATED FROM PYTHON SOURCE LINES 32-34 Setting up the algorithm ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 34-56 .. code-block:: default # gPC options options = dict() options["order_start"] = 5 options["order_end"] = 20 options["solver"] = "LarsLasso" options["interaction_order"] = 2 options["order_max_norm"] = 0.7 options["n_cpu"] = 0 options["adaptive_sampling"] = True options["gradient_enhanced"] = True options["gradient_calculation"] = "FD_fwd" options["gradient_calculation_options"] = {"dx": 0.001, "distance_weight": -2} options["fn_results"] = fn_results options["save_session_format"] = save_session_format options["eps"] = 0.0075 options["grid"] = pygpc.Random options["grid_options"] = {"seed": 1} # define algorithm algorithm = pygpc.RegAdaptive(problem=problem, options=options) .. GENERATED FROM PYTHON SOURCE LINES 57-59 Running the gpc --------------- .. GENERATED FROM PYTHON SOURCE LINES 59-66 .. code-block:: default # Initialize gPC Session session = pygpc.Session(algorithm=algorithm) # run gPC algorithm session, coeffs, results = session.run() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Initializing gPC object... Creating initial grid () with n_grid=28.0 Initializing gPC matrix... Starting adaptive sampling: Extending grid from 28 to 28 by 0 sampling points Performing simulations 1 to 28 It/Sub-it: 5/2 Performing simulation 01 from 28 [= ] 3.6% Total parallel function evaluation: 0.006276369094848633 sec It/Sub-it: 5/2 Performing simulation 01 from 56 [ ] 1.8% Gradient evaluation: 0.0005824565887451172 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.043991804122924805 sec -> relative loocv error = 5.377542041076339 Extending grid from 28 to 29 by 1 sampling points Performing simulations 29 to 29 It/Sub-it: 5/2 Performing simulation 1 from 1 [========================================] 100.0% Total parallel function evaluation: 0.005603790283203125 sec It/Sub-it: 5/2 Performing simulation 1 from 2 [==================== ] 50.0% Gradient evaluation: 0.0005440711975097656 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.043187856674194336 sec -> relative loocv error = 5.4389255100332 Order/Interaction order: 6/1 ============================ Starting adaptive sampling: Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.05651235580444336 sec -> relative loocv error = 2.7424898356615115 Starting adaptive sampling: Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.05181598663330078 sec -> relative loocv error = 0.2706490419013213 Order/Interaction order: 7/1 ============================ Starting adaptive sampling: Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.1637439727783203 sec -> relative loocv error = 2.166994676373574 Extending grid from 29 to 31 by 2 sampling points Performing simulations 30 to 31 It/Sub-it: 7/1 Performing simulation 1 from 2 [==================== ] 50.0% Total parallel function evaluation: 0.00604701042175293 sec It/Sub-it: 7/1 Performing simulation 1 from 4 [========== ] 25.0% Gradient evaluation: 0.0006062984466552734 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.07811856269836426 sec -> relative loocv error = 0.5750523757165803 Extending grid from 31 to 33 by 2 sampling points Performing simulations 32 to 33 It/Sub-it: 7/1 Performing simulation 1 from 2 [==================== ] 50.0% Total parallel function evaluation: 0.0058994293212890625 sec It/Sub-it: 7/1 Performing simulation 1 from 4 [========== ] 25.0% Gradient evaluation: 0.0005195140838623047 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.07593035697937012 sec -> relative loocv error = 0.24863210863921048 Extending grid from 33 to 35 by 2 sampling points Performing simulations 34 to 35 It/Sub-it: 7/1 Performing simulation 1 from 2 [==================== ] 50.0% Total parallel function evaluation: 0.00604701042175293 sec It/Sub-it: 7/1 Performing simulation 1 from 4 [========== ] 25.0% Gradient evaluation: 0.00048422813415527344 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.08003425598144531 sec -> relative loocv error = 0.28953840725742275 Starting adaptive sampling: Extending grid from 35 to 37 by 2 sampling points Performing simulations 36 to 37 It/Sub-it: 7/2 Performing simulation 1 from 2 [==================== ] 50.0% Total parallel function evaluation: 0.005279541015625 sec It/Sub-it: 7/2 Performing simulation 1 from 4 [========== ] 25.0% Gradient evaluation: 0.0005128383636474609 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.07238507270812988 sec -> relative loocv error = 0.5931898041382196 Extending grid from 37 to 39 by 2 sampling points Performing simulations 38 to 39 It/Sub-it: 7/2 Performing simulation 1 from 2 [==================== ] 50.0% Total parallel function evaluation: 0.006007194519042969 sec It/Sub-it: 7/2 Performing simulation 1 from 4 [========== ] 25.0% Gradient evaluation: 0.0005488395690917969 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.060982465744018555 sec -> relative loocv error = 0.577730672588717 Order/Interaction order: 8/1 ============================ Starting adaptive sampling: Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.11690235137939453 sec -> relative loocv error = 0.07013088550854302 Starting adaptive sampling: Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.09050297737121582 sec -> relative loocv error = 0.11129548131752019 Extending grid from 39 to 41 by 2 sampling points Performing simulations 40 to 41 It/Sub-it: 8/2 Performing simulation 1 from 2 [==================== ] 50.0% Total parallel function evaluation: 0.006171464920043945 sec It/Sub-it: 8/2 Performing simulation 1 from 4 [========== ] 25.0% Gradient evaluation: 0.0005750656127929688 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.08337211608886719 sec -> relative loocv error = 0.11827342483956584 Order/Interaction order: 9/1 ============================ Starting adaptive sampling: Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.16336321830749512 sec -> relative loocv error = 0.12504479993150708 Extending grid from 41 to 43 by 2 sampling points Performing simulations 42 to 43 It/Sub-it: 9/1 Performing simulation 1 from 2 [==================== ] 50.0% Total parallel function evaluation: 0.006613254547119141 sec It/Sub-it: 9/1 Performing simulation 1 from 4 [========== ] 25.0% Gradient evaluation: 0.0006575584411621094 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.13547492027282715 sec -> relative loocv error = 0.07020897203877206 Extending grid from 43 to 45 by 2 sampling points Performing simulations 44 to 45 It/Sub-it: 9/1 Performing simulation 1 from 2 [==================== ] 50.0% Total parallel function evaluation: 0.009029865264892578 sec It/Sub-it: 9/1 Performing simulation 1 from 4 [========== ] 25.0% Gradient evaluation: 0.0007212162017822266 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.13698387145996094 sec -> relative loocv error = 0.06337373123600874 Starting adaptive sampling: Extending grid from 45 to 47 by 2 sampling points Performing simulations 46 to 47 It/Sub-it: 9/2 Performing simulation 1 from 2 [==================== ] 50.0% Total parallel function evaluation: 0.006031513214111328 sec It/Sub-it: 9/2 Performing simulation 1 from 4 [========== ] 25.0% Gradient evaluation: 0.0005385875701904297 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.13159584999084473 sec -> relative loocv error = 0.031183973071024478 Extending grid from 47 to 49 by 2 sampling points Performing simulations 48 to 49 It/Sub-it: 9/2 Performing simulation 1 from 2 [==================== ] 50.0% Total parallel function evaluation: 0.006354570388793945 sec It/Sub-it: 9/2 Performing simulation 1 from 4 [========== ] 25.0% Gradient evaluation: 0.0008597373962402344 sec Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.12259411811828613 sec -> relative loocv error = 0.02068268619927386 Order/Interaction order: 10/1 ============================= Starting adaptive sampling: Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... LOOCV 01 from 25 [= ] 4.0% LOOCV 02 from 25 [=== ] 8.0% LOOCV 03 from 25 [==== ] 12.0% LOOCV 04 from 25 [====== ] 16.0% LOOCV 05 from 25 [======== ] 20.0% LOOCV 06 from 25 [========= ] 24.0% LOOCV 07 from 25 [=========== ] 28.0% LOOCV 08 from 25 [============ ] 32.0% LOOCV 09 from 25 [============== ] 36.0% LOOCV 10 from 25 [================ ] 40.0% LOOCV 11 from 25 [================= ] 44.0% LOOCV 12 from 25 [=================== ] 48.0% LOOCV 13 from 25 [==================== ] 52.0% LOOCV 14 from 25 [====================== ] 56.0% LOOCV 15 from 25 [======================== ] 60.0% LOOCV 16 from 25 [========================= ] 64.0% LOOCV 17 from 25 [=========================== ] 68.0% LOOCV 18 from 25 [============================ ] 72.0% LOOCV 19 from 25 [============================== ] 76.0% LOOCV 20 from 25 [================================ ] 80.0% LOOCV 21 from 25 [================================= ] 84.0% LOOCV 22 from 25 [=================================== ] 88.0% LOOCV 23 from 25 [==================================== ] 92.0% LOOCV 24 from 25 [====================================== ] 96.0% LOOCV 25 from 25 [========================================] 100.0% LOOCV computation time: 0.16002273559570312 sec -> relative loocv error = 0.0037572748491800927 Determine gPC coefficients using 'LarsLasso' solver (gradient enhanced)... .. GENERATED FROM PYTHON SOURCE LINES 67-69 Postprocessing -------------- .. GENERATED FROM PYTHON SOURCE LINES 69-82 .. code-block:: default # read session session = pygpc.read_session(fname=session.fn_session, folder=session.fn_session_folder) # Post-process gPC pygpc.get_sensitivities_hdf5(fn_gpc=options["fn_results"], output_idx=None, calc_sobol=True, calc_global_sens=True, calc_pdf=True, algorithm="sampling", n_samples=1e3) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none > Loading gpc session object: tmp/regadaptive.pkl > Loading gpc coeffs: tmp/regadaptive.hdf5 > Adding results to: tmp/regadaptive.hdf5 .. GENERATED FROM PYTHON SOURCE LINES 83-87 Validation ---------- Validate gPC vs original model function (2D-surface) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 87-95 .. code-block:: default pygpc.validate_gpc_plot(session=session, coeffs=coeffs, random_vars=list(problem.parameters_random.keys()), n_grid=[51, 51], output_idx=[0], fn_out=None, folder=None, n_cpu=session.n_cpu) .. image-sg:: /auto_algorithms/images/sphx_glr_plot_algorithm_regadaptive_001.png :alt: Original model, gPC approximation, Difference (Original vs gPC) :srcset: /auto_algorithms/images/sphx_glr_plot_algorithm_regadaptive_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 96-98 Validate gPC vs original model function (Monte Carlo) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 98-115 .. code-block:: default nrmsd = pygpc.validate_gpc_mc(session=session, coeffs=coeffs, n_samples=int(1e4), output_idx=[0], fn_out=None, folder=None, plot=True, n_cpu=session.n_cpu) print("> Maximum NRMSD (gpc vs original): {:.2}%".format(max(nrmsd))) # On Windows subprocesses will import (i.e. execute) the main module at start. # You need to insert an if __name__ == '__main__': guard in the main module to avoid # creating subprocesses recursively. # # if __name__ == '__main__': # main() .. image-sg:: /auto_algorithms/images/sphx_glr_plot_algorithm_regadaptive_002.png :alt: plot algorithm regadaptive :srcset: /auto_algorithms/images/sphx_glr_plot_algorithm_regadaptive_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none > Maximum NRMSD (gpc vs original): 0.0025% .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 3.509 seconds) .. _sphx_glr_download_auto_algorithms_plot_algorithm_regadaptive.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_algorithm_regadaptive.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_algorithm_regadaptive.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_