.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/mlearning/calibration/plot_calibration.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_examples_mlearning_calibration_plot_calibration.py: Calibration of a polynomial regression ====================================== .. GENERATED FROM PYTHON SOURCE LINES 24-32 .. code-block:: default import matplotlib.pyplot as plt from gemseo.algos.design_space import DesignSpace from gemseo.api import configure_logger from gemseo.mlearning.core.calibration import MLAlgoCalibration from gemseo.mlearning.qual_measure.mse_measure import MSEMeasure from gemseo.problems.dataset.rosenbrock import RosenbrockDataset from matplotlib.tri import Triangulation .. GENERATED FROM PYTHON SOURCE LINES 33-35 Load the dataset ---------------- .. GENERATED FROM PYTHON SOURCE LINES 35-37 .. code-block:: default dataset = RosenbrockDataset(opt_naming=False, n_samples=25) .. GENERATED FROM PYTHON SOURCE LINES 38-40 Define the measure ------------------ .. GENERATED FROM PYTHON SOURCE LINES 40-44 .. code-block:: default configure_logger() test_dataset = RosenbrockDataset(opt_naming=False) measure_options = {"method": "test", "test_data": test_dataset} .. GENERATED FROM PYTHON SOURCE LINES 45-49 Calibrate the degree of the polynomial regression ------------------------------------------------- Define and execute the calibration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 49-65 .. code-block:: default calibration_space = DesignSpace() calibration_space.add_variable("degree", 1, "integer", 1, 10, 1) calibration = MLAlgoCalibration( "PolynomialRegressor", dataset, ["degree"], calibration_space, MSEMeasure, measure_options, ) calibration.execute({"algo": "fullfact", "n_samples": 10}) x_opt = calibration.optimal_parameters f_opt = calibration.optimal_criterion print("optimal degree:", x_opt["degree"][0]) print("optimal criterion:", f_opt) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none INFO - 10:06:25: INFO - 10:06:25: *** Start DOEScenario execution *** INFO - 10:06:25: DOEScenario INFO - 10:06:25: Disciplines: MLAlgoAssessor INFO - 10:06:25: MDO formulation: DisciplinaryOpt INFO - 10:06:25: Optimization problem: INFO - 10:06:25: minimize criterion(degree) INFO - 10:06:25: with respect to degree INFO - 10:06:25: over the design space: INFO - 10:06:25: +--------+-------------+-------+-------------+---------+ INFO - 10:06:25: | name | lower_bound | value | upper_bound | type | INFO - 10:06:25: +--------+-------------+-------+-------------+---------+ INFO - 10:06:25: | degree | 1 | 1 | 10 | integer | INFO - 10:06:25: +--------+-------------+-------+-------------+---------+ INFO - 10:06:25: Solving optimization problem with algorithm fullfact: INFO - 10:06:25: Full factorial design required. Number of samples along each direction for a design vector of size 1 with 10 samples: 10 INFO - 10:06:25: Final number of samples for DOE = 10 vs 10 requested INFO - 10:06:25: ... 0%| | 0/10 [00:00` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_calibration.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_