API

Here are some examples of the machine learning API applied to clustering models.

Import

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()

Get available clustering models

print(get_clustering_models())

Out:

['GaussianMixture', 'KMeans']

Get clustering model options

print(get_clustering_options("GaussianMixture"))

Out:

{'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']}

Create clustering model

iris = load_dataset("IrisDataset")

model = create_clustering_model("KMeans", data=iris, n_clusters=3)
model.learn()

print(model)

Out:

KMeans(var_names=None, n_clusters=3, random_state=0)
| built from 150 learning samples

Total running time of the script: ( 0 minutes 0.041 seconds)

Gallery generated by Sphinx-Gallery