.. 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:15:48: *** Start DOEScenario execution *** INFO - 16:15:48: DOEScenario INFO - 16:15:48: Disciplines: MLAlgoAssessor INFO - 16:15:48: MDO formulation: DisciplinaryOpt INFO - 16:15:48: Optimization problem: INFO - 16:15:48: minimize criterion(epsilon) INFO - 16:15:48: with respect to epsilon INFO - 16:15:48: over the design space: INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | epsilon | 0.01 | 0.05 | 0.1 | float | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:15:48: 6%|▋ | 1/16 [00:00<00:00, 67.83 it/sec, feas=True, obj=0.00433] INFO - 16:15:48: 12%|█▎ | 2/16 [00:00<00:00, 72.95 it/sec, feas=True, obj=0.00767] INFO - 16:15:48: 19%|█▉ | 3/16 [00:00<00:00, 74.00 it/sec, feas=True, obj=0.0154] INFO - 16:15:48: 25%|██▌ | 4/16 [00:00<00:00, 75.08 it/sec, feas=True, obj=0.032] INFO - 16:15:48: 31%|███▏ | 5/16 [00:00<00:00, 75.53 it/sec, feas=True, obj=0.0645] INFO - 16:15:48: 38%|███▊ | 6/16 [00:00<00:00, 75.85 it/sec, feas=True, obj=0.123] INFO - 16:15:48: 44%|████▍ | 7/16 [00:00<00:00, 76.13 it/sec, feas=True, obj=0.223] INFO - 16:15:48: 50%|█████ | 8/16 [00:00<00:00, 76.45 it/sec, feas=True, obj=0.382] INFO - 16:15:48: 56%|█████▋ | 9/16 [00:00<00:00, 76.57 it/sec, feas=True, obj=0.62] INFO - 16:15:48: 62%|██████▎ | 10/16 [00:00<00:00, 76.78 it/sec, feas=True, obj=0.962] INFO - 16:15:48: 69%|██████▉ | 11/16 [00:00<00:00, 76.92 it/sec, feas=True, obj=1.43] INFO - 16:15:48: 75%|███████▌ | 12/16 [00:00<00:00, 77.09 it/sec, feas=True, obj=2.05] INFO - 16:15:48: 81%|████████▏ | 13/16 [00:00<00:00, 77.19 it/sec, feas=True, obj=2.85] INFO - 16:15:48: 88%|████████▊ | 14/16 [00:00<00:00, 77.33 it/sec, feas=True, obj=3.84] INFO - 16:15:48: 94%|█████████▍| 15/16 [00:00<00:00, 77.31 it/sec, feas=True, obj=5.05] INFO - 16:15:48: 100%|██████████| 16/16 [00:00<00:00, 77.31 it/sec, feas=True, obj=6.51] INFO - 16:15:48: Optimization result: INFO - 16:15:48: Optimizer info: INFO - 16:15:48: Status: None INFO - 16:15:48: Message: None INFO - 16:15:48: Solution: INFO - 16:15:48: Objective: 0.004329869274089288 INFO - 16:15:48: Design space: INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | epsilon | 0.01 | 0.01 | 0.1 | float | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: *** End DOEScenario execution *** INFO - 16:15:48: *** Start DOEScenario execution *** INFO - 16:15:48: DOEScenario INFO - 16:15:48: Disciplines: MLAlgoAssessor INFO - 16:15:48: MDO formulation: DisciplinaryOpt INFO - 16:15:48: Optimization problem: INFO - 16:15:48: minimize criterion(epsilon) INFO - 16:15:48: with respect to epsilon INFO - 16:15:48: over the design space: INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | epsilon | 0.01 | 0.01 | 0.1 | float | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:15:48: 6%|▋ | 1/16 [00:00<00:00, 67.70 it/sec, feas=True, obj=0.00392] INFO - 16:15:48: 12%|█▎ | 2/16 [00:00<00:00, 72.22 it/sec, feas=True, obj=0.00489] INFO - 16:15:48: 19%|█▉ | 3/16 [00:00<00:00, 74.27 it/sec, feas=True, obj=0.0056] INFO - 16:15:48: 25%|██▌ | 4/16 [00:00<00:00, 75.43 it/sec, feas=True, obj=0.00582] INFO - 16:15:48: 31%|███▏ | 5/16 [00:00<00:00, 76.25 it/sec, feas=True, obj=0.00558] INFO - 16:15:48: 38%|███▊ | 6/16 [00:00<00:00, 76.49 it/sec, feas=True, obj=0.00512] INFO - 16:15:48: 44%|████▍ | 7/16 [00:00<00:00, 76.78 it/sec, feas=True, obj=0.00454] INFO - 16:15:48: 50%|█████ | 8/16 [00:00<00:00, 77.00 it/sec, feas=True, obj=0.00395] INFO - 16:15:48: 56%|█████▋ | 9/16 [00:00<00:00, 77.31 it/sec, feas=True, obj=0.00343] INFO - 16:15:48: 62%|██████▎ | 10/16 [00:00<00:00, 77.57 it/sec, feas=True, obj=0.00304] INFO - 16:15:48: 69%|██████▉ | 11/16 [00:00<00:00, 77.69 it/sec, feas=True, obj=0.00277] INFO - 16:15:48: 75%|███████▌ | 12/16 [00:00<00:00, 77.86 it/sec, feas=True, obj=0.00258] INFO - 16:15:48: 81%|████████▏ | 13/16 [00:00<00:00, 78.05 it/sec, feas=True, obj=0.00246] INFO - 16:15:48: 88%|████████▊ | 14/16 [00:00<00:00, 78.09 it/sec, feas=True, obj=0.00237] INFO - 16:15:48: 94%|█████████▍| 15/16 [00:00<00:00, 78.13 it/sec, feas=True, obj=0.00231] INFO - 16:15:48: 100%|██████████| 16/16 [00:00<00:00, 78.10 it/sec, feas=True, obj=0.00226] INFO - 16:15:48: Optimization result: INFO - 16:15:48: Optimizer info: INFO - 16:15:48: Status: None INFO - 16:15:48: Message: None INFO - 16:15:48: Solution: INFO - 16:15:48: Objective: 0.0022624675787187524 INFO - 16:15:48: Design space: INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | epsilon | 0.01 | 0.1 | 0.1 | float | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: *** End DOEScenario execution *** INFO - 16:15:48: *** Start DOEScenario execution *** INFO - 16:15:48: DOEScenario INFO - 16:15:48: Disciplines: MLAlgoAssessor INFO - 16:15:48: MDO formulation: DisciplinaryOpt INFO - 16:15:48: Optimization problem: INFO - 16:15:48: minimize criterion(epsilon) INFO - 16:15:48: with respect to epsilon INFO - 16:15:48: over the design space: INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | epsilon | 0.01 | 0.1 | 0.1 | float | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:15:48: 6%|▋ | 1/16 [00:00<00:00, 68.23 it/sec, feas=True, obj=0.00305] INFO - 16:15:48: 12%|█▎ | 2/16 [00:00<00:00, 72.87 it/sec, feas=True, obj=0.00307] INFO - 16:15:48: 19%|█▉ | 3/16 [00:00<00:00, 74.20 it/sec, feas=True, obj=0.00297] INFO - 16:15:48: 25%|██▌ | 4/16 [00:00<00:00, 75.10 it/sec, feas=True, obj=0.0028] INFO - 16:15:48: 31%|███▏ | 5/16 [00:00<00:00, 75.80 it/sec, feas=True, obj=0.00263] INFO - 16:15:48: 38%|███▊ | 6/16 [00:00<00:00, 76.22 it/sec, feas=True, obj=0.00251] INFO - 16:15:48: 44%|████▍ | 7/16 [00:00<00:00, 76.57 it/sec, feas=True, obj=0.00242] INFO - 16:15:48: 50%|█████ | 8/16 [00:00<00:00, 76.95 it/sec, feas=True, obj=0.00237] INFO - 16:15:48: 56%|█████▋ | 9/16 [00:00<00:00, 77.13 it/sec, feas=True, obj=0.00233] INFO - 16:15:48: 62%|██████▎ | 10/16 [00:00<00:00, 77.32 it/sec, feas=True, obj=0.0023] INFO - 16:15:48: 69%|██████▉ | 11/16 [00:00<00:00, 77.49 it/sec, feas=True, obj=0.00228] INFO - 16:15:48: 75%|███████▌ | 12/16 [00:00<00:00, 77.58 it/sec, feas=True, obj=0.00226] INFO - 16:15:48: 81%|████████▏ | 13/16 [00:00<00:00, 77.59 it/sec, feas=True, obj=0.00224] INFO - 16:15:48: 88%|████████▊ | 14/16 [00:00<00:00, 77.24 it/sec, feas=True, obj=0.00223] INFO - 16:15:48: 94%|█████████▍| 15/16 [00:00<00:00, 77.31 it/sec, feas=True, obj=0.00222] INFO - 16:15:48: 100%|██████████| 16/16 [00:00<00:00, 77.35 it/sec, feas=True, obj=0.00221] INFO - 16:15:48: Optimization result: INFO - 16:15:48: Optimizer info: INFO - 16:15:48: Status: None INFO - 16:15:48: Message: None INFO - 16:15:48: Solution: INFO - 16:15:48: Objective: 0.002207251533907032 INFO - 16:15:48: Design space: INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | epsilon | 0.01 | 0.1 | 0.1 | float | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: *** End DOEScenario execution *** INFO - 16:15:48: *** Start DOEScenario execution *** INFO - 16:15:48: DOEScenario INFO - 16:15:48: Disciplines: MLAlgoAssessor INFO - 16:15:48: MDO formulation: DisciplinaryOpt INFO - 16:15:48: Optimization problem: INFO - 16:15:48: minimize criterion(epsilon) INFO - 16:15:48: with respect to epsilon INFO - 16:15:48: over the design space: INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: | epsilon | 0.01 | 0.1 | 0.1 | float | INFO - 16:15:48: +---------+-------------+-------+-------------+-------+ INFO - 16:15:48: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:15:48: 6%|▋ | 1/16 [00:00<00:00, 67.12 it/sec, feas=True, obj=0.00254] INFO - 16:15:48: 12%|█▎ | 2/16 [00:00<00:00, 71.81 it/sec, feas=True, obj=0.0025] INFO - 16:15:48: 19%|█▉ | 3/16 [00:00<00:00, 73.71 it/sec, feas=True, obj=0.00248] INFO - 16:15:48: 25%|██▌ | 4/16 [00:00<00:00, 74.85 it/sec, feas=True, obj=0.00248] INFO - 16:15:48: 31%|███▏ | 5/16 [00:00<00:00, 75.57 it/sec, feas=True, obj=0.00248] INFO - 16:15:48: 38%|███▊ | 6/16 [00:00<00:00, 76.17 it/sec, feas=True, obj=0.0025] INFO - 16:15:48: 44%|████▍ | 7/16 [00:00<00:00, 76.59 it/sec, feas=True, obj=0.00253] INFO - 16:15:48: 50%|█████ | 8/16 [00:00<00:00, 76.69 it/sec, feas=True, obj=0.00256] INFO - 16:15:48: 56%|█████▋ | 9/16 [00:00<00:00, 76.92 it/sec, feas=True, obj=0.00259] INFO - 16:15:49: 62%|██████▎ | 10/16 [00:00<00:00, 77.02 it/sec, feas=True, obj=0.00263] INFO - 16:15:49: 69%|██████▉ | 11/16 [00:00<00:00, 77.21 it/sec, feas=True, obj=0.00267] INFO - 16:15:49: 75%|███████▌ | 12/16 [00:00<00:00, 77.33 it/sec, feas=True, obj=0.00272] INFO - 16:15:49: 81%|████████▏ | 13/16 [00:00<00:00, 77.44 it/sec, feas=True, obj=0.00276] INFO - 16:15:49: 88%|████████▊ | 14/16 [00:00<00:00, 77.45 it/sec, feas=True, obj=0.00281] INFO - 16:15:49: 94%|█████████▍| 15/16 [00:00<00:00, 77.56 it/sec, feas=True, obj=0.00286] INFO - 16:15:49: 100%|██████████| 16/16 [00:00<00:00, 77.63 it/sec, feas=True, obj=0.00291] INFO - 16:15:49: Optimization result: INFO - 16:15:49: Optimizer info: INFO - 16:15:49: Status: None INFO - 16:15:49: Message: None INFO - 16:15:49: Solution: INFO - 16:15:49: Objective: 0.002476990894836162 INFO - 16:15:49: Design space: INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: | epsilon | 0.01 | 0.028 | 0.1 | float | INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: *** End DOEScenario execution *** INFO - 16:15:49: *** Start DOEScenario execution *** INFO - 16:15:49: DOEScenario INFO - 16:15:49: Disciplines: MLAlgoAssessor INFO - 16:15:49: MDO formulation: DisciplinaryOpt INFO - 16:15:49: Optimization problem: INFO - 16:15:49: minimize criterion(epsilon) INFO - 16:15:49: with respect to epsilon INFO - 16:15:49: over the design space: INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: | epsilon | 0.01 | 0.028 | 0.1 | float | INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:15:49: 6%|▋ | 1/16 [00:00<00:00, 69.48 it/sec, feas=True, obj=0.00292] INFO - 16:15:49: 12%|█▎ | 2/16 [00:00<00:00, 73.16 it/sec, feas=True, obj=0.00326] INFO - 16:15:49: 19%|█▉ | 3/16 [00:00<00:00, 74.32 it/sec, feas=True, obj=0.00361] INFO - 16:15:49: 25%|██▌ | 4/16 [00:00<00:00, 75.30 it/sec, feas=True, obj=0.00398] INFO - 16:15:49: 31%|███▏ | 5/16 [00:00<00:00, 75.96 it/sec, feas=True, obj=0.00435] INFO - 16:15:49: 38%|███▊ | 6/16 [00:00<00:00, 76.32 it/sec, feas=True, obj=0.00474] INFO - 16:15:49: 44%|████▍ | 7/16 [00:00<00:00, 76.65 it/sec, feas=True, obj=0.00513] INFO - 16:15:49: 50%|█████ | 8/16 [00:00<00:00, 76.96 it/sec, feas=True, obj=0.00553] INFO - 16:15:49: 56%|█████▋ | 9/16 [00:00<00:00, 77.15 it/sec, feas=True, obj=0.00594] INFO - 16:15:49: 62%|██████▎ | 10/16 [00:00<00:00, 77.29 it/sec, feas=True, obj=0.00636] INFO - 16:15:49: 69%|██████▉ | 11/16 [00:00<00:00, 77.46 it/sec, feas=True, obj=0.00679] INFO - 16:15:49: 75%|███████▌ | 12/16 [00:00<00:00, 77.52 it/sec, feas=True, obj=0.00723] INFO - 16:15:49: 81%|████████▏ | 13/16 [00:00<00:00, 77.69 it/sec, feas=True, obj=0.00767] INFO - 16:15:49: 88%|████████▊ | 14/16 [00:00<00:00, 77.81 it/sec, feas=True, obj=0.00813] INFO - 16:15:49: 94%|█████████▍| 15/16 [00:00<00:00, 77.81 it/sec, feas=True, obj=0.00859] INFO - 16:15:49: 100%|██████████| 16/16 [00:00<00:00, 77.87 it/sec, feas=True, obj=0.00906] INFO - 16:15:49: Optimization result: INFO - 16:15:49: Optimizer info: INFO - 16:15:49: Status: None INFO - 16:15:49: Message: None INFO - 16:15:49: Solution: INFO - 16:15:49: Objective: 0.002919064447634629 INFO - 16:15:49: Design space: INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: | epsilon | 0.01 | 0.01 | 0.1 | float | INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: *** End DOEScenario execution *** INFO - 16:15:49: *** Start DOEScenario execution *** INFO - 16:15:49: DOEScenario INFO - 16:15:49: Disciplines: MLAlgoAssessor INFO - 16:15:49: MDO formulation: DisciplinaryOpt INFO - 16:15:49: Optimization problem: INFO - 16:15:49: minimize criterion(epsilon) INFO - 16:15:49: with respect to epsilon INFO - 16:15:49: over the design space: INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: | epsilon | 0.01 | 0.01 | 0.1 | float | INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: Solving optimization problem with algorithm PYDOE_FULLFACT: INFO - 16:15:49: 6%|▋ | 1/16 [00:00<00:00, 68.86 it/sec, feas=True, obj=0.00846] INFO - 16:15:49: 12%|█▎ | 2/16 [00:00<00:00, 73.12 it/sec, feas=True, obj=0.0119] INFO - 16:15:49: 19%|█▉ | 3/16 [00:00<00:00, 75.05 it/sec, feas=True, obj=0.0148] INFO - 16:15:49: 25%|██▌ | 4/16 [00:00<00:00, 75.80 it/sec, feas=True, obj=0.0172] INFO - 16:15:49: 31%|███▏ | 5/16 [00:00<00:00, 76.49 it/sec, feas=True, obj=0.019] INFO - 16:15:49: 38%|███▊ | 6/16 [00:00<00:00, 76.81 it/sec, feas=True, obj=0.0213] INFO - 16:15:49: 44%|████▍ | 7/16 [00:00<00:00, 76.84 it/sec, feas=True, obj=0.0921] INFO - 16:15:49: 50%|█████ | 8/16 [00:00<00:00, 76.96 it/sec, feas=True, obj=11.9] INFO - 16:15:49: 56%|█████▋ | 9/16 [00:00<00:00, 77.17 it/sec, feas=True, obj=0.0761] INFO - 16:15:49: 62%|██████▎ | 10/16 [00:00<00:00, 76.64 it/sec, feas=True, obj=0.0533] INFO - 16:15:49: 69%|██████▉ | 11/16 [00:00<00:00, 76.76 it/sec, feas=True, obj=0.0483] INFO - 16:15:49: 75%|███████▌ | 12/16 [00:00<00:00, 76.86 it/sec, feas=True, obj=0.0466] INFO - 16:15:49: 81%|████████▏ | 13/16 [00:00<00:00, 76.95 it/sec, feas=True, obj=0.0461] INFO - 16:15:49: 88%|████████▊ | 14/16 [00:00<00:00, 77.00 it/sec, feas=True, obj=0.0461] INFO - 16:15:49: 94%|█████████▍| 15/16 [00:00<00:00, 77.13 it/sec, feas=True, obj=0.0464] INFO - 16:15:49: 100%|██████████| 16/16 [00:00<00:00, 77.12 it/sec, feas=True, obj=0.0468] INFO - 16:15:49: Optimization result: INFO - 16:15:49: Optimizer info: INFO - 16:15:49: Status: None INFO - 16:15:49: Message: None INFO - 16:15:49: Solution: INFO - 16:15:49: Objective: 0.00846290490101175 INFO - 16:15:49: Design space: INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: | epsilon | 0.01 | 0.01 | 0.1 | float | INFO - 16:15:49: +---------+-------------+-------+-------------+-------+ INFO - 16:15:49: *** 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.022 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 `_