Classification API

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

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

Out:

<RootLogger root (INFO)>

Get available classification models

print(get_classification_models())

Out:

['KNNClassifier', 'RandomForestClassifier', 'SVMClassifier']

Get classification model options

print(get_classification_options("KNNClassifier"))

Out:

{'$schema': 'http://json-schema.org/schema#', 'type': 'object', 'properties': {'transformer': {'type': 'null'}, 'input_names': {'type': 'null'}, 'output_names': {'type': 'null'}, 'n_neighbors': {'description': 'The number of neighbors.', 'type': 'integer'}}, 'required': ['n_neighbors']}

Create classification model

iris = load_dataset("IrisDataset", as_io=True)

model = create_classification_model("KNNClassifier", data=iris)
model.learn()

print(model)

Out:

KNNClassifier(n_neighbors=5)
   based on the scikit-learn library
   built from 150 learning samples

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

Gallery generated by Sphinx-Gallery