.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/mlearning/regression_model/plot_regression_api.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_regression_model_plot_regression_api.py: High-level functions ==================== The :mod:`gemseo.mlearning` package includes high-level functions to create regression models from model class names. .. GENERATED FROM PYTHON SOURCE LINES 28-36 .. code-block:: Python from __future__ import annotations from gemseo import create_benchmark_dataset from gemseo.mlearning import create_regression_model from gemseo.mlearning import get_regression_models from gemseo.mlearning import get_regression_options .. GENERATED FROM PYTHON SOURCE LINES 37-41 Available models ---------------- Use the :func:`.get_regression_models` to list the available model class names: .. GENERATED FROM PYTHON SOURCE LINES 41-43 .. code-block:: Python get_regression_models() .. rst-class:: sphx-glr-script-out .. code-block:: none ['FCERegressor', 'GaussianProcessRegressor', 'GradientBoostingRegressor', 'LinearRegressor', 'MLPRegressor', 'MOERegressor', 'OTGaussianProcessRegressor', 'PCERegressor', 'PolynomialRegressor', 'RBFRegressor', 'RandomForestRegressor', 'RegressorChain', 'SVMRegressor', 'TPSRegressor'] .. GENERATED FROM PYTHON SOURCE LINES 44-49 Available model options ----------------------- Use the :func:`.get_regression_options` to get the options of a model from its class name: .. GENERATED FROM PYTHON SOURCE LINES 49-51 .. code-block:: Python get_regression_options("GaussianProcessRegressor", pretty_print=False) .. rst-class:: sphx-glr-script-out .. code-block:: none {'additionalProperties': False, 'description': 'The settings of the Gaussian process regressor from scikit-learn.', 'properties': {'transformer': {'additionalProperties': True, 'description': 'The strategies to transform the variables.\n\nThe values are instances of :class:`.BaseTransformer`\nwhile the keys are the names of\neither the variables\nor the groups of variables,\ne.g. ``"inputs"`` or ``"outputs"``\nin the case of the regression algorithms.\nIf a group is specified,\nthe :class:`.BaseTransformer` will be applied\nto all the variables of this group.\nIf :attr:`.IDENTITY`, do not transform the variables.', 'title': 'Transformer', 'type': 'object'}, 'parameters': {'additionalProperties': True, 'description': 'Other parameters.', 'title': 'Parameters', 'type': 'object'}, 'input_names': {'default': [], 'description': 'The names of the input variables', 'items': {'type': 'string'}, 'title': 'Input Names', 'type': 'array'}, 'output_names': {'default': [], 'description': 'The names of the output variables', 'items': {'type': 'string'}, 'title': 'Output Names', 'type': 'array'}, 'kernel': {'anyOf': [{}, {'type': 'null'}], 'default': None, 'description': 'The kernel specifying the covariance model.\n\nIf ``None``, use a Matérn(2.5).', 'title': 'Kernel'}, 'bounds': {'anyOf': [{'items': {}, 'type': 'array'}, {'maxItems': 2, 'minItems': 2, 'prefixItems': [{'type': 'number'}, {'type': 'number'}], 'type': 'array'}, {'additionalProperties': {'maxItems': 2, 'minItems': 2, 'prefixItems': [{'type': 'number'}, {'type': 'number'}], 'type': 'array'}, 'type': 'object'}], 'default': [], 'description': 'The lower and upper bounds of the length scales.\n\nEither a unique lower-upper pair common to all the inputs\nor lower-upper pairs for some of them.\nWhen ``bounds`` is empty or when an input has no pair,\nthe lower bound is 0.01 and the upper bound is 100.\n\nThis argument is ignored when ``kernel`` is ``None``.', 'title': 'Bounds'}, 'alpha': {'default': 1e-10, 'description': 'The nugget effect to regularize the model.', 'title': 'Alpha', 'type': 'number'}, 'optimizer': {'anyOf': [{'type': 'string'}, {}], 'default': 'fmin_l_bfgs_b', 'description': 'The optimization algorithm to find the parameter length scales.', 'title': 'Optimizer'}, 'n_restarts_optimizer': {'default': 10, 'description': 'The number of restarts of the optimizer.', 'minimum': 0, 'title': 'N Restarts Optimizer', 'type': 'integer'}, 'random_state': {'anyOf': [{'minimum': 0, 'type': 'integer'}, {'type': 'null'}], 'default': 0, 'description': 'The random state parameter.\n\nIf ``None``, use the global random state instance from ``numpy.random``.\nCreating the model multiple times will produce different results.\nIf ``int``, use a new random number generator seeded by this integer.\nThis will produce the same results.', 'title': 'Random State'}}, 'title': 'GaussianProcessRegressor_Settings', 'type': 'object'} .. GENERATED FROM PYTHON SOURCE LINES 52-63 .. seealso:: The functions :func:`.get_regression_models` and :func:`.get_regression_options` can be very useful for the developers. As a user, it may be easier to consult :ref:`this page ` to find out about the different algorithms and their options. Creation -------- Given a training dataset, *e.g.* .. GENERATED FROM PYTHON SOURCE LINES 64-65 .. code-block:: Python dataset = create_benchmark_dataset("RosenbrockDataset", opt_naming=False) .. GENERATED FROM PYTHON SOURCE LINES 66-68 use the :func:`.create_regression_model` function to create a clustering model from its class name and settings: .. GENERATED FROM PYTHON SOURCE LINES 68-70 .. code-block:: Python model = create_regression_model("RBFRegressor", data=dataset) model.learn() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.008 seconds) .. _sphx_glr_download_examples_mlearning_regression_model_plot_regression_api.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_regression_api.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_regression_api.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_regression_api.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_