.. 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 26-37 .. code-block:: default from __future__ import division, unicode_literals import matplotlib.pyplot as plt from matplotlib.tri import Triangulation 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 .. GENERATED FROM PYTHON SOURCE LINES 38-40 Load the dataset ---------------- .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: default dataset = RosenbrockDataset(opt_naming=False, n_samples=25) .. GENERATED FROM PYTHON SOURCE LINES 43-45 Define the measure ------------------ .. GENERATED FROM PYTHON SOURCE LINES 45-49 .. code-block:: default configure_logger() test_dataset = RosenbrockDataset(opt_naming=False) measure_options = {"method": "test", "test_data": test_dataset} .. GENERATED FROM PYTHON SOURCE LINES 50-54 Calibrate the degree of the polynomial regression ------------------------------------------------- Define and execute the calibration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 54-70 .. code-block:: default calibration_space = DesignSpace() calibration_space.add_variable("degree", 1, "integer", 1, 10, 1) calibration = MLAlgoCalibration( "PolynomialRegression", 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 - 14:41:00: INFO - 14:41:00: *** Start DOE Scenario execution *** INFO - 14:41:00: DOEScenario INFO - 14:41:00: Disciplines: MLAlgoAssessor INFO - 14:41:00: MDOFormulation: DisciplinaryOpt INFO - 14:41:00: Algorithm: fullfact INFO - 14:41:00: Optimization problem: INFO - 14:41:00: Minimize: criterion(degree) INFO - 14:41:00: With respect to: degree INFO - 14:41:00: Full factorial design required. Number of samples along each direction for a design vector of size 1 with 10 samples: 10 INFO - 14:41:00: Final number of samples for DOE = 10 vs 10 requested INFO - 14:41:00: DOE sampling: 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 `_