.. 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 Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_mlearning_classification_model_plot_classification_api.py: Classification API ================== Here are some examples of the machine learning API applied to classification models. .. GENERATED FROM PYTHON SOURCE LINES 30-42 .. code-block:: default from __future__ import division, unicode_literals from gemseo.api import configure_logger, load_dataset from gemseo.mlearning.api import ( create_classification_model, get_classification_models, get_classification_options, ) configure_logger() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 43-45 Get available classification models ----------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 45-47 .. code-block:: default print(get_classification_models()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none ['KNNClassifier', 'RandomForestClassifier', 'SVMClassifier'] .. GENERATED FROM PYTHON SOURCE LINES 48-50 Get classification model options -------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 50-52 .. code-block:: default print(get_classification_options("KNNClassifier")) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none +---------------------------+--------------------------------------------------------------------------------------------+---------------------------+ | Name | Description | Type | +---------------------------+--------------------------------------------------------------------------------------------+---------------------------+ | input_names | The names of the input variables. if none, consider all input variables mentioned in the | null | | | learning dataset. | | | n_neighbors | The number of neighbors. | integer | | output_names | The names of the output variables. if none, consider all input variables mentioned in the | null | | | learning dataset. | | | transformer | The strategies to transform the variables. the values are instances of | null | | | :class:`.transformer` while the keys are the names of either the variables or the groups | | | | of variables, e.g. "inputs" or "outputs" in the case of the regression algorithms. if a | | | | group is specified, the :class:`.transformer` will be applied to all the variables of this | | | | group. if none, do not transform the variables. | | +---------------------------+--------------------------------------------------------------------------------------------+---------------------------+ INFO - 21:50:10: +---------------------------+--------------------------------------------------------------------------------------------+---------------------------+ INFO - 21:50:10: | Name | Description | Type | INFO - 21:50:10: +---------------------------+--------------------------------------------------------------------------------------------+---------------------------+ INFO - 21:50:10: | input_names | The names of the input variables. if none, consider all input variables mentioned in the | null | INFO - 21:50:10: | | learning dataset. | | INFO - 21:50:10: | n_neighbors | The number of neighbors. | integer | INFO - 21:50:10: | output_names | The names of the output variables. if none, consider all input variables mentioned in the | null | INFO - 21:50:10: | | learning dataset. | | INFO - 21:50:10: | transformer | The strategies to transform the variables. the values are instances of | null | INFO - 21:50:10: | | :class:`.transformer` while the keys are the names of either the variables or the groups | | INFO - 21:50:10: | | of variables, e.g. "inputs" or "outputs" in the case of the regression algorithms. if a | | INFO - 21:50:10: | | group is specified, the :class:`.transformer` will be applied to all the variables of this | | INFO - 21:50:10: | | group. if none, do not transform the variables. | | INFO - 21:50:10: +---------------------------+--------------------------------------------------------------------------------------------+---------------------------+ {'$schema': 'http://json-schema.org/schema#', 'type': 'object', 'properties': {'transformer': {'description': 'The strategies to transform the variables. The values are instances of :class:`.Transformer` while the keys are the names of either the variables or the groups of variables, e.g. "inputs" or "outputs" in the case of the regression algorithms. If a group is specified, the :class:`.Transformer` will be applied to all the variables of this group. If None, do not transform the variables.', 'type': 'null'}, 'input_names': {'description': 'The names of the input variables. If None, consider all input variables mentioned in the learning dataset.', 'type': 'null'}, 'output_names': {'description': 'The names of the output variables. If None, consider all input variables mentioned in the learning dataset.', 'type': 'null'}, 'n_neighbors': {'description': 'The number of neighbors.', 'type': 'integer'}}, 'required': ['n_neighbors']} .. GENERATED FROM PYTHON SOURCE LINES 53-55 Create classification model --------------------------- .. GENERATED FROM PYTHON SOURCE LINES 55-61 .. code-block:: default iris = load_dataset("IrisDataset", as_io=True) model = create_classification_model("KNNClassifier", data=iris) model.learn() print(model) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none KNNClassifier(n_neighbors=5) based on the scikit-learn library built from 150 learning samples .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.054 seconds) .. _sphx_glr_download_examples_mlearning_classification_model_plot_classification_api.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_classification_api.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_classification_api.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_