org.apache.ignite.ml.clustering.kmeans

## Class KMeansTrainer

- java.lang.Object
- - org.apache.ignite.ml.trainers.DatasetTrainer<M,Double>
  - - org.apache.ignite.ml.trainers.SingleLabelDatasetTrainer<KMeansModel>
    - - org.apache.ignite.ml.clustering.kmeans.KMeansTrainer

-     public class KMeansTrainer
      extends SingleLabelDatasetTrainer<KMeansModel>

  The trainer for KMeans algorithm.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `KMeansTrainer.TotalCostAndCounts` Service class used for statistics.

    - ### Nested classes/interfaces inherited from class org.apache.ignite.ml.trainers.DatasetTrainer

      `DatasetTrainer.EmptyDatasetException`

  - ### Field Summary

    - ### Fields inherited from class org.apache.ignite.ml.trainers.DatasetTrainer

      `envBuilder, environment`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `KMeansTrainer()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<K,V> KMeansModel` | `fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> preprocessor)` Trains model based on the specified data.
    `int` | `getAmountOfClusters()` Gets the amount of clusters.
    `DistanceMeasure` | `getDistance()` Gets the distance.
    `double` | `getEpsilon()` Gets the epsilon.
    `int` | `getMaxIterations()` Gets the max number of iterations before convergence.
    `boolean` | `isUpdateable(KMeansModel mdl)`
    `protected <K,V> KMeansModel` | `updateModel(KMeansModel mdl, DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> preprocessor)` Gets state of model in arguments, update in according to new data and return new model.
    `KMeansTrainer` | `withAmountOfClusters(int k)` Set up the amount of clusters.
    `KMeansTrainer` | `withDistance(DistanceMeasure distance)` Set up the distance.
    `KMeansTrainer` | `withEnvironmentBuilder(LearningEnvironmentBuilder envBuilder)` Changes learning Environment.
    `KMeansTrainer` | `withEpsilon(double epsilon)` Set up the epsilon.
    `KMeansTrainer` | `withMaxIterations(int maxIterations)` Set up the max number of iterations before convergence.

    - ### Methods inherited from class org.apache.ignite.ml.trainers.DatasetTrainer

      `fit, fit, fit, fit, fit, fit, getLastTrainedModelOrThrowEmptyDatasetException, identityTrainer, learningEnvironment, update, update, update, update, update, withConvertedLabels`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### KMeansTrainer

          public KMeansTrainer()

  - ### Method Detail

    - #### fitWithInitializedDeployingContext

          public <K,V> KMeansModel fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder,
                                                                      Preprocessor<K,V> preprocessor)

      Trains model based on the specified data.
      Specified by:
        `fitWithInitializedDeployingContext` in class `DatasetTrainer<KMeansModel,Double>`
      Type Parameters:
        `K` - Type of a key in `upstream` data.
        `V` - Type of a value in `upstream` data.
      Parameters:
        `datasetBuilder` - Dataset builder.
        `preprocessor` - Extractor of `UpstreamEntry` into `LabeledVector`.
      Returns:
        Model.

    - #### withEnvironmentBuilder

          public KMeansTrainer withEnvironmentBuilder(LearningEnvironmentBuilder envBuilder)

      Changes learning Environment.
      Overrides:
        `withEnvironmentBuilder` in class `DatasetTrainer<KMeansModel,Double>`
      Parameters:
        `envBuilder` - Learning environment builder.

    - #### updateModel

          protected <K,V> KMeansModel updateModel(KMeansModel mdl,
                                                  DatasetBuilder<K,V> datasetBuilder,
                                                  Preprocessor<K,V> preprocessor)

      Gets state of model in arguments, update in according to new data and return new model.
      Specified by:
        `updateModel` in class `DatasetTrainer<KMeansModel,Double>`
      Type Parameters:
        `K` - Type of a key in `upstream` data.
        `V` - Type of a value in `upstream` data.
      Parameters:
        `mdl` - Learned model.
        `datasetBuilder` - Dataset builder.
        `preprocessor` - Extractor of `UpstreamEntry` into `LabeledVector`.
      Returns:
        Updated model.

    - #### isUpdateable

          public boolean isUpdateable(KMeansModel mdl)

      Specified by:
        `isUpdateable` in class `DatasetTrainer<KMeansModel,Double>`
      Parameters:
        `mdl` - Model.
      Returns:
        True if current critical for training parameters correspond to parameters from last training.

    - #### getAmountOfClusters

          public int getAmountOfClusters()

      Gets the amount of clusters.
      Returns:
        The parameter value.

    - #### withAmountOfClusters

          public KMeansTrainer withAmountOfClusters(int k)

      Set up the amount of clusters.
      Parameters:
        `k` - The parameter value.
      Returns:
        Model with new amount of clusters parameter value.

    - #### getMaxIterations

          public int getMaxIterations()

      Gets the max number of iterations before convergence.
      Returns:
        The parameter value.

    - #### withMaxIterations

          public KMeansTrainer withMaxIterations(int maxIterations)

      Set up the max number of iterations before convergence.
      Parameters:
        `maxIterations` - The parameter value.
      Returns:
        Model with new max number of iterations before convergence parameter value.

    - #### getEpsilon

          public double getEpsilon()

      Gets the epsilon.
      Returns:
        The parameter value.

    - #### withEpsilon

          public KMeansTrainer withEpsilon(double epsilon)

      Set up the epsilon.
      Parameters:
        `epsilon` - The parameter value.
      Returns:
        Model with new epsilon parameter value.

    - #### getDistance

          public DistanceMeasure getDistance()

      Gets the distance.
      Returns:
        The parameter value.

    - #### withDistance

          public KMeansTrainer withDistance(DistanceMeasure distance)

      Set up the distance.
      Parameters:
        `distance` - The parameter value.
      Returns:
        Model with new distance parameter value.

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022