.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/mlearning/calibration/plot_selection.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_mlearning_calibration_plot_selection.py: Machine learning algorithm selection example ============================================ In this example we use the :class:`.MLAlgoSelection` class to perform a grid search over different algorithms and hyperparameter values. .. GENERATED FROM PYTHON SOURCE LINES 23-38 .. code-block:: Python from __future__ import annotations import matplotlib.pyplot as plt from numpy import linspace from numpy import sort from numpy.random import default_rng from gemseo.algos.design_space import DesignSpace from gemseo.datasets.io_dataset import IODataset from gemseo.mlearning.core.selection import MLAlgoSelection from gemseo.mlearning.regression.quality.mse_measure import MSEMeasure rng = default_rng(54321) .. GENERATED FROM PYTHON SOURCE LINES 39-48 Build dataset ------------- The data are generated from the function :math:`f(x)=x^2`. The input data :math:`\{x_i\}_{i=1,\cdots,20}` are chosen at random over the interval :math:`[0,1]`. The output value :math:`y_i = f(x_i) + \varepsilon_i` corresponds to the evaluation of :math:`f` at :math:`x_i` corrupted by a Gaussian noise :math:`\varepsilon_i` with zero mean and standard deviation :math:`\sigma=0.05`. .. GENERATED FROM PYTHON SOURCE LINES 48-56 .. code-block:: Python n = 20 x = sort(rng.random(n)) y = x**2 + rng.normal(0, 0.05, n) dataset = IODataset() dataset.add_variable("x", x[:, None], dataset.INPUT_GROUP) dataset.add_variable("y", y[:, None], dataset.OUTPUT_GROUP) .. GENERATED FROM PYTHON SOURCE LINES 57-62 Build selector -------------- We consider three regression models, with different possible hyperparameters. A mean squared error quality measure is used with a k-folds cross validation scheme (5 folds). .. GENERATED FROM PYTHON SOURCE LINES 62-87 .. code-block:: Python selector = MLAlgoSelection( dataset, MSEMeasure, measure_evaluation_method_name="KFOLDS", n_folds=5 ) selector.add_candidate( "LinearRegressor", penalty_level=[0, 0.1, 1, 10, 20], l2_penalty_ratio=[0, 0.5, 1], fit_intercept=[True], ) selector.add_candidate( "PolynomialRegressor", degree=[2, 3, 4, 10], penalty_level=[0, 0.1, 1, 10], l2_penalty_ratio=[1], fit_intercept=[True, False], ) rbf_space = DesignSpace() rbf_space.add_variable("epsilon", 1, "float", 0.01, 0.1, 0.05) selector.add_candidate( "RBFRegressor", calib_space=rbf_space, calib_algo={"algo_name": "PYDOE_FULLFACT", "n_samples": 16}, smooth=[0, 0.01, 0.1, 1, 10, 100], ) .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 16:21:59: *** Start DOEScenario execution *** INFO - 16:21:59: DOEScenario INFO - 16:21:59: Disciplines: MLAlgoAssessor INFO - 16:21:59: MDO formulation: DisciplinaryOpt INFO - 16:21:59: Optimization problem: INFO - 16:21:59: minimize criterion(epsilon) INFO - 16:21:59: with respect to epsilon INFO - 16:21:59: over the design space: INFO - 16:21:59: +---------+-------------+-------+-------------+-------+ INFO - 16:21:59: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:21:59: +---------+-------------+-------+-------------+-------+ INFO - 16:21:59: | epsilon | 0.01 | 0.05 | 0.1 | float | INFO - 16:21:59: +---------+-------------+-------+-------------+-------+ INFO - 16:21:59: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:21:59: 6%|▋ | 1/16 [00:00<00:00, 66.73 it/sec, feas=True, obj=0.00433] INFO - 16:21:59: 12%|█▎ | 2/16 [00:00<00:00, 71.89 it/sec, feas=True, obj=0.00767] INFO - 16:21:59: 19%|█▉ | 3/16 [00:00<00:00, 73.38 it/sec, feas=True, obj=0.0154] INFO - 16:21:59: 25%|██▌ | 4/16 [00:00<00:00, 74.74 it/sec, feas=True, obj=0.032] INFO - 16:22:00: 31%|███▏ | 5/16 [00:00<00:00, 75.47 it/sec, feas=True, obj=0.0645] INFO - 16:22:00: 38%|███▊ | 6/16 [00:00<00:00, 75.56 it/sec, feas=True, obj=0.123] INFO - 16:22:00: 44%|████▍ | 7/16 [00:00<00:00, 75.69 it/sec, feas=True, obj=0.223] INFO - 16:22:00: 50%|█████ | 8/16 [00:00<00:00, 75.97 it/sec, feas=True, obj=0.382] INFO - 16:22:00: 56%|█████▋ | 9/16 [00:00<00:00, 76.08 it/sec, feas=True, obj=0.62] INFO - 16:22:00: 62%|██████▎ | 10/16 [00:00<00:00, 76.14 it/sec, feas=True, obj=0.962] INFO - 16:22:00: 69%|██████▉ | 11/16 [00:00<00:00, 76.19 it/sec, feas=True, obj=1.43] INFO - 16:22:00: 75%|███████▌ | 12/16 [00:00<00:00, 76.31 it/sec, feas=True, obj=2.05] INFO - 16:22:00: 81%|████████▏ | 13/16 [00:00<00:00, 76.34 it/sec, feas=True, obj=2.85] INFO - 16:22:00: 88%|████████▊ | 14/16 [00:00<00:00, 76.40 it/sec, feas=True, obj=3.84] INFO - 16:22:00: 94%|█████████▍| 15/16 [00:00<00:00, 76.38 it/sec, feas=True, obj=5.05] INFO - 16:22:00: 100%|██████████| 16/16 [00:00<00:00, 76.38 it/sec, feas=True, obj=6.51] INFO - 16:22:00: Optimization result: INFO - 16:22:00: Optimizer info: INFO - 16:22:00: Status: None INFO - 16:22:00: Message: None INFO - 16:22:00: Solution: INFO - 16:22:00: Objective: 0.004329869274089288 INFO - 16:22:00: Design space: INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | epsilon | 0.01 | 0.01 | 0.1 | float | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: *** End DOEScenario execution *** INFO - 16:22:00: *** Start DOEScenario execution *** INFO - 16:22:00: DOEScenario INFO - 16:22:00: Disciplines: MLAlgoAssessor INFO - 16:22:00: MDO formulation: DisciplinaryOpt INFO - 16:22:00: Optimization problem: INFO - 16:22:00: minimize criterion(epsilon) INFO - 16:22:00: with respect to epsilon INFO - 16:22:00: over the design space: INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | epsilon | 0.01 | 0.01 | 0.1 | float | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:22:00: 6%|▋ | 1/16 [00:00<00:00, 65.36 it/sec, feas=True, obj=0.00392] INFO - 16:22:00: 12%|█▎ | 2/16 [00:00<00:00, 70.40 it/sec, feas=True, obj=0.00489] INFO - 16:22:00: 19%|█▉ | 3/16 [00:00<00:00, 73.10 it/sec, feas=True, obj=0.0056] INFO - 16:22:00: 25%|██▌ | 4/16 [00:00<00:00, 74.62 it/sec, feas=True, obj=0.00582] INFO - 16:22:00: 31%|███▏ | 5/16 [00:00<00:00, 75.38 it/sec, feas=True, obj=0.00558] INFO - 16:22:00: 38%|███▊ | 6/16 [00:00<00:00, 75.67 it/sec, feas=True, obj=0.00512] INFO - 16:22:00: 44%|████▍ | 7/16 [00:00<00:00, 76.17 it/sec, feas=True, obj=0.00454] INFO - 16:22:00: 50%|█████ | 8/16 [00:00<00:00, 76.40 it/sec, feas=True, obj=0.00395] INFO - 16:22:00: 56%|█████▋ | 9/16 [00:00<00:00, 76.74 it/sec, feas=True, obj=0.00343] INFO - 16:22:00: 62%|██████▎ | 10/16 [00:00<00:00, 77.01 it/sec, feas=True, obj=0.00304] INFO - 16:22:00: 69%|██████▉ | 11/16 [00:00<00:00, 77.14 it/sec, feas=True, obj=0.00277] INFO - 16:22:00: 75%|███████▌ | 12/16 [00:00<00:00, 77.33 it/sec, feas=True, obj=0.00258] INFO - 16:22:00: 81%|████████▏ | 13/16 [00:00<00:00, 77.52 it/sec, feas=True, obj=0.00246] INFO - 16:22:00: 88%|████████▊ | 14/16 [00:00<00:00, 77.61 it/sec, feas=True, obj=0.00237] INFO - 16:22:00: 94%|█████████▍| 15/16 [00:00<00:00, 77.76 it/sec, feas=True, obj=0.00231] INFO - 16:22:00: 100%|██████████| 16/16 [00:00<00:00, 77.80 it/sec, feas=True, obj=0.00226] INFO - 16:22:00: Optimization result: INFO - 16:22:00: Optimizer info: INFO - 16:22:00: Status: None INFO - 16:22:00: Message: None INFO - 16:22:00: Solution: INFO - 16:22:00: Objective: 0.0022624675787187524 INFO - 16:22:00: Design space: INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | epsilon | 0.01 | 0.1 | 0.1 | float | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: *** End DOEScenario execution *** INFO - 16:22:00: *** Start DOEScenario execution *** INFO - 16:22:00: DOEScenario INFO - 16:22:00: Disciplines: MLAlgoAssessor INFO - 16:22:00: MDO formulation: DisciplinaryOpt INFO - 16:22:00: Optimization problem: INFO - 16:22:00: minimize criterion(epsilon) INFO - 16:22:00: with respect to epsilon INFO - 16:22:00: over the design space: INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | epsilon | 0.01 | 0.1 | 0.1 | float | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:22:00: 6%|▋ | 1/16 [00:00<00:00, 69.56 it/sec, feas=True, obj=0.00305] INFO - 16:22:00: 12%|█▎ | 2/16 [00:00<00:00, 74.26 it/sec, feas=True, obj=0.00307] INFO - 16:22:00: 19%|█▉ | 3/16 [00:00<00:00, 75.25 it/sec, feas=True, obj=0.00297] INFO - 16:22:00: 25%|██▌ | 4/16 [00:00<00:00, 76.19 it/sec, feas=True, obj=0.0028] INFO - 16:22:00: 31%|███▏ | 5/16 [00:00<00:00, 76.96 it/sec, feas=True, obj=0.00263] INFO - 16:22:00: 38%|███▊ | 6/16 [00:00<00:00, 77.18 it/sec, feas=True, obj=0.00251] INFO - 16:22:00: 44%|████▍ | 7/16 [00:00<00:00, 77.57 it/sec, feas=True, obj=0.00242] INFO - 16:22:00: 50%|█████ | 8/16 [00:00<00:00, 77.84 it/sec, feas=True, obj=0.00237] INFO - 16:22:00: 56%|█████▋ | 9/16 [00:00<00:00, 77.85 it/sec, feas=True, obj=0.00233] INFO - 16:22:00: 62%|██████▎ | 10/16 [00:00<00:00, 77.97 it/sec, feas=True, obj=0.0023] INFO - 16:22:00: 69%|██████▉ | 11/16 [00:00<00:00, 78.04 it/sec, feas=True, obj=0.00228] INFO - 16:22:00: 75%|███████▌ | 12/16 [00:00<00:00, 78.10 it/sec, feas=True, obj=0.00226] INFO - 16:22:00: 81%|████████▏ | 13/16 [00:00<00:00, 78.25 it/sec, feas=True, obj=0.00224] INFO - 16:22:00: 88%|████████▊ | 14/16 [00:00<00:00, 77.78 it/sec, feas=True, obj=0.00223] INFO - 16:22:00: 94%|█████████▍| 15/16 [00:00<00:00, 77.78 it/sec, feas=True, obj=0.00222] INFO - 16:22:00: 100%|██████████| 16/16 [00:00<00:00, 77.84 it/sec, feas=True, obj=0.00221] INFO - 16:22:00: Optimization result: INFO - 16:22:00: Optimizer info: INFO - 16:22:00: Status: None INFO - 16:22:00: Message: None INFO - 16:22:00: Solution: INFO - 16:22:00: Objective: 0.002207251533907032 INFO - 16:22:00: Design space: INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | epsilon | 0.01 | 0.1 | 0.1 | float | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: *** End DOEScenario execution *** INFO - 16:22:00: *** Start DOEScenario execution *** INFO - 16:22:00: DOEScenario INFO - 16:22:00: Disciplines: MLAlgoAssessor INFO - 16:22:00: MDO formulation: DisciplinaryOpt INFO - 16:22:00: Optimization problem: INFO - 16:22:00: minimize criterion(epsilon) INFO - 16:22:00: with respect to epsilon INFO - 16:22:00: over the design space: INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | epsilon | 0.01 | 0.1 | 0.1 | float | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:22:00: 6%|▋ | 1/16 [00:00<00:00, 66.68 it/sec, feas=True, obj=0.00254] INFO - 16:22:00: 12%|█▎ | 2/16 [00:00<00:00, 66.97 it/sec, feas=True, obj=0.0025] INFO - 16:22:00: 19%|█▉ | 3/16 [00:00<00:00, 70.49 it/sec, feas=True, obj=0.00248] INFO - 16:22:00: 25%|██▌ | 4/16 [00:00<00:00, 72.58 it/sec, feas=True, obj=0.00248] INFO - 16:22:00: 31%|███▏ | 5/16 [00:00<00:00, 73.85 it/sec, feas=True, obj=0.00248] INFO - 16:22:00: 38%|███▊ | 6/16 [00:00<00:00, 74.67 it/sec, feas=True, obj=0.0025] INFO - 16:22:00: 44%|████▍ | 7/16 [00:00<00:00, 75.31 it/sec, feas=True, obj=0.00253] INFO - 16:22:00: 50%|█████ | 8/16 [00:00<00:00, 75.55 it/sec, feas=True, obj=0.00256] INFO - 16:22:00: 56%|█████▋ | 9/16 [00:00<00:00, 75.87 it/sec, feas=True, obj=0.00259] INFO - 16:22:00: 62%|██████▎ | 10/16 [00:00<00:00, 76.09 it/sec, feas=True, obj=0.00263] INFO - 16:22:00: 69%|██████▉ | 11/16 [00:00<00:00, 76.24 it/sec, feas=True, obj=0.00267] INFO - 16:22:00: 75%|███████▌ | 12/16 [00:00<00:00, 76.45 it/sec, feas=True, obj=0.00272] INFO - 16:22:00: 81%|████████▏ | 13/16 [00:00<00:00, 76.69 it/sec, feas=True, obj=0.00276] INFO - 16:22:00: 88%|████████▊ | 14/16 [00:00<00:00, 76.79 it/sec, feas=True, obj=0.00281] INFO - 16:22:00: 94%|█████████▍| 15/16 [00:00<00:00, 76.17 it/sec, feas=True, obj=0.00286] INFO - 16:22:00: 100%|██████████| 16/16 [00:00<00:00, 76.36 it/sec, feas=True, obj=0.00291] INFO - 16:22:00: Optimization result: INFO - 16:22:00: Optimizer info: INFO - 16:22:00: Status: None INFO - 16:22:00: Message: None INFO - 16:22:00: Solution: INFO - 16:22:00: Objective: 0.002476990894836162 INFO - 16:22:00: Design space: INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | epsilon | 0.01 | 0.028 | 0.1 | float | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: *** End DOEScenario execution *** INFO - 16:22:00: *** Start DOEScenario execution *** INFO - 16:22:00: DOEScenario INFO - 16:22:00: Disciplines: MLAlgoAssessor INFO - 16:22:00: MDO formulation: DisciplinaryOpt INFO - 16:22:00: Optimization problem: INFO - 16:22:00: minimize criterion(epsilon) INFO - 16:22:00: with respect to epsilon INFO - 16:22:00: over the design space: INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: | epsilon | 0.01 | 0.028 | 0.1 | float | INFO - 16:22:00: +---------+-------------+-------+-------------+-------+ INFO - 16:22:00: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:22:00: 6%|▋ | 1/16 [00:00<00:00, 66.37 it/sec, feas=True, obj=0.00292] INFO - 16:22:00: 12%|█▎ | 2/16 [00:00<00:00, 71.90 it/sec, feas=True, obj=0.00326] INFO - 16:22:00: 19%|█▉ | 3/16 [00:00<00:00, 73.66 it/sec, feas=True, obj=0.00361] INFO - 16:22:00: 25%|██▌ | 4/16 [00:00<00:00, 74.98 it/sec, feas=True, obj=0.00398] INFO - 16:22:00: 31%|███▏ | 5/16 [00:00<00:00, 75.95 it/sec, feas=True, obj=0.00435] INFO - 16:22:00: 38%|███▊ | 6/16 [00:00<00:00, 76.46 it/sec, feas=True, obj=0.00474] INFO - 16:22:00: 44%|████▍ | 7/16 [00:00<00:00, 76.86 it/sec, feas=True, obj=0.00513] INFO - 16:22:00: 50%|█████ | 8/16 [00:00<00:00, 77.23 it/sec, feas=True, obj=0.00553] INFO - 16:22:00: 56%|█████▋ | 9/16 [00:00<00:00, 77.41 it/sec, feas=True, obj=0.00594] INFO - 16:22:00: 62%|██████▎ | 10/16 [00:00<00:00, 77.69 it/sec, feas=True, obj=0.00636] INFO - 16:22:00: 69%|██████▉ | 11/16 [00:00<00:00, 77.87 it/sec, feas=True, obj=0.00679] INFO - 16:22:00: 75%|███████▌ | 12/16 [00:00<00:00, 78.00 it/sec, feas=True, obj=0.00723] INFO - 16:22:00: 81%|████████▏ | 13/16 [00:00<00:00, 78.14 it/sec, feas=True, obj=0.00767] INFO - 16:22:00: 88%|████████▊ | 14/16 [00:00<00:00, 78.26 it/sec, feas=True, obj=0.00813] INFO - 16:22:00: 94%|█████████▍| 15/16 [00:00<00:00, 78.27 it/sec, feas=True, obj=0.00859] INFO - 16:22:01: 100%|██████████| 16/16 [00:00<00:00, 78.29 it/sec, feas=True, obj=0.00906] INFO - 16:22:01: Optimization result: INFO - 16:22:01: Optimizer info: INFO - 16:22:01: Status: None INFO - 16:22:01: Message: None INFO - 16:22:01: Solution: INFO - 16:22:01: Objective: 0.002919064447634629 INFO - 16:22:01: Design space: INFO - 16:22:01: +---------+-------------+-------+-------------+-------+ INFO - 16:22:01: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:01: +---------+-------------+-------+-------------+-------+ INFO - 16:22:01: | epsilon | 0.01 | 0.01 | 0.1 | float | INFO - 16:22:01: +---------+-------------+-------+-------------+-------+ INFO - 16:22:01: *** End DOEScenario execution *** INFO - 16:22:01: *** Start DOEScenario execution *** INFO - 16:22:01: DOEScenario INFO - 16:22:01: Disciplines: MLAlgoAssessor INFO - 16:22:01: MDO formulation: DisciplinaryOpt INFO - 16:22:01: Optimization problem: INFO - 16:22:01: minimize criterion(epsilon) INFO - 16:22:01: with respect to epsilon INFO - 16:22:01: over the design space: INFO - 16:22:01: +---------+-------------+-------+-------------+-------+ INFO - 16:22:01: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:01: +---------+-------------+-------+-------------+-------+ INFO - 16:22:01: | epsilon | 0.01 | 0.01 | 0.1 | float | INFO - 16:22:01: +---------+-------------+-------+-------------+-------+ INFO - 16:22:01: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:22:01: 6%|▋ | 1/16 [00:00<00:00, 69.61 it/sec, feas=True, obj=0.00846] INFO - 16:22:01: 12%|█▎ | 2/16 [00:00<00:00, 73.90 it/sec, feas=True, obj=0.0119] INFO - 16:22:01: 19%|█▉ | 3/16 [00:00<00:00, 75.89 it/sec, feas=True, obj=0.0148] INFO - 16:22:01: 25%|██▌ | 4/16 [00:00<00:00, 76.72 it/sec, feas=True, obj=0.0172] INFO - 16:22:01: 31%|███▏ | 5/16 [00:00<00:00, 77.44 it/sec, feas=True, obj=0.019] INFO - 16:22:01: 38%|███▊ | 6/16 [00:00<00:00, 77.91 it/sec, feas=True, obj=0.0213] INFO - 16:22:01: 44%|████▍ | 7/16 [00:00<00:00, 78.07 it/sec, feas=True, obj=0.0921] INFO - 16:22:01: 50%|█████ | 8/16 [00:00<00:00, 78.28 it/sec, feas=True, obj=11.9] INFO - 16:22:01: 56%|█████▋ | 9/16 [00:00<00:00, 78.43 it/sec, feas=True, obj=0.0761] INFO - 16:22:01: 62%|██████▎ | 10/16 [00:00<00:00, 77.91 it/sec, feas=True, obj=0.0533] INFO - 16:22:01: 69%|██████▉ | 11/16 [00:00<00:00, 78.01 it/sec, feas=True, obj=0.0483] INFO - 16:22:01: 75%|███████▌ | 12/16 [00:00<00:00, 78.10 it/sec, feas=True, obj=0.0466] INFO - 16:22:01: 81%|████████▏ | 13/16 [00:00<00:00, 78.18 it/sec, feas=True, obj=0.0461] INFO - 16:22:01: 88%|████████▊ | 14/16 [00:00<00:00, 78.25 it/sec, feas=True, obj=0.0461] INFO - 16:22:01: 94%|█████████▍| 15/16 [00:00<00:00, 78.32 it/sec, feas=True, obj=0.0464] INFO - 16:22:01: 100%|██████████| 16/16 [00:00<00:00, 78.23 it/sec, feas=True, obj=0.0468] INFO - 16:22:01: Optimization result: INFO - 16:22:01: Optimizer info: INFO - 16:22:01: Status: None INFO - 16:22:01: Message: None INFO - 16:22:01: Solution: INFO - 16:22:01: Objective: 0.00846290490101175 INFO - 16:22:01: Design space: INFO - 16:22:01: +---------+-------------+-------+-------------+-------+ INFO - 16:22:01: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:22:01: +---------+-------------+-------+-------------+-------+ INFO - 16:22:01: | epsilon | 0.01 | 0.01 | 0.1 | float | INFO - 16:22:01: +---------+-------------+-------+-------------+-------+ INFO - 16:22:01: *** End DOEScenario execution *** .. GENERATED FROM PYTHON SOURCE LINES 88-90 Select best candidate --------------------- .. GENERATED FROM PYTHON SOURCE LINES 90-93 .. code-block:: Python best_algo = selector.select() best_algo .. raw:: html
PolynomialRegressor(degree=4, fit_intercept=True, input_names=(), l2_penalty_ratio=1.0, output_names=(), parameters={}, penalty_level=0.0, random_state=0, transformer={})
  • based on the scikit-learn library
  • built from 20 learning samples


.. GENERATED FROM PYTHON SOURCE LINES 94-97 Plot results ------------ Plot the best models from each candidate algorithm .. GENERATED FROM PYTHON SOURCE LINES 97-106 .. code-block:: Python finex = linspace(0, 1, 1000) for candidate in selector.candidates: algo = candidate[0] print(algo) predy = algo.predict(finex[:, None])[:, 0] plt.plot(finex, predy, label=algo.SHORT_ALGO_NAME) plt.scatter(x, y, label="Training points") plt.legend() plt.show() .. image-sg:: /examples/mlearning/calibration/images/sphx_glr_plot_selection_001.png :alt: plot selection :srcset: /examples/mlearning/calibration/images/sphx_glr_plot_selection_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none LinearRegressor(fit_intercept=True, input_names=(), l2_penalty_ratio=0.0, output_names=(), parameters={}, penalty_level=0.0, random_state=0, transformer={}) based on the scikit-learn library built from 20 learning samples PolynomialRegressor(degree=4, fit_intercept=True, input_names=(), l2_penalty_ratio=1.0, output_names=(), parameters={}, penalty_level=0.0, random_state=0, transformer={}) based on the scikit-learn library built from 20 learning samples RBFRegressor(der_function=None, epsilon=0.1, function=multiquadric, input_names=(), norm=euclidean, output_names=(), parameters={}, smooth=0.1, transformer={}) based on the SciPy library built from 20 learning samples .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.029 seconds) .. _sphx_glr_download_examples_mlearning_calibration_plot_selection.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_selection.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_selection.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_selection.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_