.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/mlearning/clustering_model/plot_clustering_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_clustering_model_plot_clustering_api.py: API === Here are some examples of the machine learning API applied to clustering models. .. GENERATED FROM PYTHON SOURCE LINES 32-34 Import ------ .. GENERATED FROM PYTHON SOURCE LINES 34-49 .. code-block:: default from __future__ import absolute_import, division, print_function, unicode_literals from future import standard_library from gemseo.api import configure_logger, load_dataset from gemseo.mlearning.api import ( create_clustering_model, get_clustering_models, get_clustering_options, ) configure_logger() standard_library.install_aliases() .. GENERATED FROM PYTHON SOURCE LINES 50-52 Get available clustering models ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 52-54 .. code-block:: default print(get_clustering_models()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none ['GaussianMixture', 'KMeans'] .. GENERATED FROM PYTHON SOURCE LINES 55-57 Get clustering model options ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 57-59 .. code-block:: default print(get_clustering_options("GaussianMixture")) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none {'type': 'object', 'properties': {'transformer': {'description': 'transformation strategy for data groups.\nIf None, do not transform data. Default: None.\n:type transformer: dict(str)\n'}, 'var_names': {'description': 'names of the variables to consider.\n:type var_names: list(str)\n'}, 'n_components': {'type': 'integer', 'description': 'number of Gaussian mixture components.\nDefault: 5.\n:type n_components: int\n'}}, 'required': ['n_components']} .. GENERATED FROM PYTHON SOURCE LINES 60-62 Create clustering model ----------------------- .. GENERATED FROM PYTHON SOURCE LINES 62-68 .. code-block:: default iris = load_dataset("IrisDataset") model = create_clustering_model("KMeans", data=iris, n_clusters=3) model.learn() print(model) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none KMeans(var_names=None, n_clusters=3, random_state=0) | built from 150 learning samples .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.041 seconds) .. _sphx_glr_download_examples_mlearning_clustering_model_plot_clustering_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_clustering_api.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_clustering_api.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_