Note
Click here to download the full example code
API¶
Here are some examples of the machine learning API applied to clustering models.
Import¶
from __future__ import division, unicode_literals
from gemseo.api import configure_logger, load_dataset
from gemseo.mlearning.api import (
create_clustering_model,
get_clustering_models,
get_clustering_options,
)
configure_logger()
Out:
<RootLogger root (INFO)>
Get available clustering models¶
print(get_clustering_models())
Out:
['GaussianMixture', 'KMeans', 'MLPredictiveClusteringAlgo']
Get clustering model options¶
print(get_clustering_options("GaussianMixture"))
Out:
{'$schema': 'http://json-schema.org/schema#', 'type': 'object', 'properties': {'transformer': {'type': 'null'}, 'var_names': {'type': 'null'}, 'n_components': {'description': 'The number of components of the Gaussian mixture.', 'type': 'integer'}}, '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(n_clusters=3, random_state=0, var_names=None)
built from 150 learning samples
Total running time of the script: ( 0 minutes 0.060 seconds)