.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/mlearning/classification_model/plot_classification_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_classification_model_plot_classification_api.py: High-level functions ==================== The :mod:`gemseo.mlearning` package includes high-level functions to create classification 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_classification_model from gemseo.mlearning import get_classification_models from gemseo.mlearning import get_classification_options .. GENERATED FROM PYTHON SOURCE LINES 37-41 Available models ---------------- Use the :func:`.get_classification_models` to list the available model class names: .. GENERATED FROM PYTHON SOURCE LINES 41-43 .. code-block:: Python get_classification_models() .. rst-class:: sphx-glr-script-out .. code-block:: none ['KNNClassifier', 'RandomForestClassifier', 'SVMClassifier'] .. GENERATED FROM PYTHON SOURCE LINES 44-49 Available model options ----------------------- Use the :func:`.get_classification_options` to get the options of a model from its class name: .. GENERATED FROM PYTHON SOURCE LINES 49-51 .. code-block:: Python get_classification_options("KNNClassifier", pretty_print=False) .. rst-class:: sphx-glr-script-out .. code-block:: none {'additionalProperties': False, 'description': 'The settings of the k-nearest neighbors classification algorithm.', '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'}, 'n_neighbors': {'default': 5, 'description': 'The number of neighbors.', 'exclusiveMinimum': 0, 'title': 'N Neighbors', 'type': 'integer'}}, 'title': 'KNNClassifier_Settings', 'type': 'object'} .. GENERATED FROM PYTHON SOURCE LINES 52-63 .. seealso:: The functions :func:`.get_classification_models` and :func:`.get_classification_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("IrisDataset", as_io=True) .. GENERATED FROM PYTHON SOURCE LINES 66-68 use the :func:`.create_classification_model` function to create a classification model from its class name and settings: .. GENERATED FROM PYTHON SOURCE LINES 68-70 .. code-block:: Python model = create_classification_model("KNNClassifier", data=dataset) model.learn() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.020 seconds) .. _sphx_glr_download_examples_mlearning_classification_model_plot_classification_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_classification_api.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_classification_api.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_classification_api.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_