.. Copyright 2021 IRT Saint-Exupéry, https://www.irt-saintexupery.com This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. .. _gen_classification_algos: Classification algorithms ========================= .. warning:: Some capabilities may require the :ref:`installation ` of |g| with :ref:`all its features ` and some others may depend on :ref:`plugins `. .. warning:: All the features of the wrapped libraries may not be exposed through |g|. .. note:: The algorithm settings can be passed to a function of the form .. code-block:: python function(..., settings_model: AlgorithmSettings | None = None, **settings: Any) either one by one: .. code-block:: python function(..., setting_name_1=setting_name_1, setting_name_2=setting_name_2, ...) or using the argument name ``"settings_model"`` and the Pydantic model associated with the algorithm: .. code-block:: python settings_model = AlgorithmSettings(setting_name_1=setting_name_1, setting_name_2=setting_name_2, ...) function(..., settings_model=settings_model) .. _KNNClassifier_options: KNNClassifier ------------- Module: :class:`gemseo.mlearning.classification.algos.knn` .. code-block:: python :caption: Pydantic model of the settings for KNNClassifier from gemseo.settings.mlearning import KNNClassifier_Settings .. raw:: html
Optional settings
  • **input_names** : *collections.abc.Sequence[str], optional* The names of the input variables By default it is set to (). .. raw:: html
  • **n_neighbors** : *, optional* The number of neighbors. By default it is set to 5. .. raw:: html
  • **output_names** : *collections.abc.Sequence[str], optional* The names of the output variables By default it is set to (). .. raw:: html
  • **parameters** : *collections.abc.Mapping[str, typing.Any], optional* Other parameters. By default it is set to {}. .. raw:: html
  • **transformer** : *collections.abc.Mapping[str, typing.Any], optional* The strategies to transform the variables. The values are instances of :class:`.BaseTransformer` 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:`.BaseTransformer` will be applied to all the variables of this group. If :attr:`.IDENTITY`, do not transform the variables. By default it is set to {}. .. raw:: html
.. _RandomForestClassifier_options: RandomForestClassifier ---------------------- Module: :class:`gemseo.mlearning.classification.algos.random_forest` .. code-block:: python :caption: Pydantic model of the settings for RandomForestClassifier from gemseo.settings.mlearning import RandomForestClassifier_Settings .. raw:: html
Optional settings
  • **input_names** : *collections.abc.Sequence[str], optional* The names of the input variables By default it is set to (). .. raw:: html
  • **n_estimators** : *, optional* The number of trees in the forest. By default it is set to 100. .. raw:: html
  • **output_names** : *collections.abc.Sequence[str], optional* The names of the output variables By default it is set to (). .. raw:: html
  • **parameters** : *collections.abc.Mapping[str, typing.Any], optional* Other parameters. By default it is set to {}. .. raw:: html
  • **random_state** : *typing.Optional[typing.Annotated[int, Ge(ge=0)]], optional* The random state parameter. If ``None``, use the global random state instance from ``numpy.random``. Creating the model multiple times will produce different results. If ``int``, use a new random number generator seeded by this integer. This will produce the same results. By default it is set to 0. .. raw:: html
  • **transformer** : *collections.abc.Mapping[str, typing.Any], optional* The strategies to transform the variables. The values are instances of :class:`.BaseTransformer` 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:`.BaseTransformer` will be applied to all the variables of this group. If :attr:`.IDENTITY`, do not transform the variables. By default it is set to {}. .. raw:: html
.. _SVMClassifier_options: SVMClassifier ------------- Module: :class:`gemseo.mlearning.classification.algos.svm` .. code-block:: python :caption: Pydantic model of the settings for SVMClassifier from gemseo.settings.mlearning import SVMClassifier_Settings .. raw:: html
Optional settings
  • **C** : *, optional* The inverse L2 regularization parameter. By default it is set to 1.0. .. raw:: html
  • **input_names** : *collections.abc.Sequence[str], optional* The names of the input variables By default it is set to (). .. raw:: html
  • **kernel** : *typing.Union[str, typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional* The name of the kernel or a callable for the SVM. Examples of names: "linear", "poly", "rbf", "sigmoid", "precomputed". By default it is set to rbf. .. raw:: html
  • **output_names** : *collections.abc.Sequence[str], optional* The names of the output variables By default it is set to (). .. raw:: html
  • **parameters** : *collections.abc.Mapping[str, typing.Any], optional* Other parameters. By default it is set to {}. .. raw:: html
  • **probability** : *, optional* Whether to enable the probability estimates. By default it is set to False. .. raw:: html
  • **random_state** : *typing.Optional[typing.Annotated[int, Ge(ge=0)]], optional* The random state parameter. If ``None``, use the global random state instance from ``numpy.random``. Creating the model multiple times will produce different results. If ``int``, use a new random number generator seeded by this integer. This will produce the same results. By default it is set to 0. .. raw:: html
  • **transformer** : *collections.abc.Mapping[str, typing.Any], optional* The strategies to transform the variables. The values are instances of :class:`.BaseTransformer` 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:`.BaseTransformer` will be applied to all the variables of this group. If :attr:`.IDENTITY`, do not transform the variables. By default it is set to {}. .. raw:: html