org.apache.ignite.ml.clustering.kmeans

## Class KMeansModel

- java.lang.Object
- - org.apache.ignite.ml.clustering.kmeans.KMeansModel

- All Implemented Interfaces:
    Serializable, AutoCloseable, ClusterizationModel<Vector,Integer>, DeployableObject, Exportable<KMeansModelFormat>, IgniteModel<Vector,Integer>, JSONWritable, Model<Vector,Integer>

      public final class KMeansModel
      extends Object
      implements ClusterizationModel<Vector,Integer>, Exportable<KMeansModelFormat>, JSONWritable, DeployableObject

  This class encapsulates result of clusterization by KMeans algorithm.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `KMeansModel.KMeansJSONExportModel`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `KMeansModel(Vector[] centers, DistanceMeasure distanceMeasure)` Construct KMeans model with given centers and distanceMeasure measure.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `amountOfClusters()` Gets the clusters count.
    `Vector[]` | `centers()` Get cluster centers.
    `DistanceMeasure` | `distanceMeasure()` Distance measure.
    `boolean` | `equals(Object obj)`
    `static KMeansModel` | `fromJSON(Path path)` Loads KMeansModel from JSON file.
    `List<Object>` | `getDependencies()` Returns dependencies of this object that can be object with class defined by client side and unknown for server.
    `int` | `hashCode()`
    `Integer` | `predict(Vector vec)` Make a prediction for the specified input arguments.
    `<P> void` | `saveModel(Exporter<KMeansModelFormat,P> exporter, P path)` Save model by the given path.
    `void` | `toJSON(Path path)`
    `String` | `toString()`
    `String` | `toString(boolean pretty)`
    `KMeansModel` | `withCentroids(Vector[] centers)` Set up the centroids.
    `KMeansModel` | `withDistanceMeasure(DistanceMeasure distanceMeasure)` Set up the distance measure.

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.ignite.ml.IgniteModel

      `andBefore, andThen, andThen, close, combine`

- - ### Constructor Detail

    - #### KMeansModel

          public KMeansModel(Vector[] centers,
                             DistanceMeasure distanceMeasure)

      Construct KMeans model with given centers and distanceMeasure measure.
      Parameters:
        `centers` - Centers.
        `distanceMeasure` - Distance measure.

  - ### Method Detail

    - #### distanceMeasure

          public DistanceMeasure distanceMeasure()

      Distance measure.

    - #### amountOfClusters

          public int amountOfClusters()

      Gets the clusters count.
      Specified by:
        `amountOfClusters` in interface `ClusterizationModel<Vector,Integer>`

    - #### withCentroids

          public KMeansModel withCentroids(Vector[] centers)

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

    - #### withDistanceMeasure

          public KMeansModel withDistanceMeasure(DistanceMeasure distanceMeasure)

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

    - #### centers

          public Vector[] centers()

      Get cluster centers.
      Specified by:
        `centers` in interface `ClusterizationModel<Vector,Integer>`

    - #### predict

          public Integer predict(Vector vec)

      Make a prediction for the specified input arguments.
      Specified by:
        `predict` in interface `Model<Vector,Integer>`
      Parameters:
        `vec` - Input arguments.
      Returns:
        Prediction result.

    - #### saveModel

          public <P> void saveModel(Exporter<KMeansModelFormat,P> exporter,
                                    P path)

      Save model by the given path.
      Specified by:
        `saveModel` in interface `Exportable<KMeansModelFormat>`
      Parameters:
        `exporter` - Exporter.
        `path` - Path to saved model.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toString

          public String toString(boolean pretty)

      Specified by:
        `toString` in interface `IgniteModel<Vector,Integer>`
      Parameters:
        `pretty` - Use pretty mode.

    - #### getDependencies

          public List<Object> getDependencies()

      Returns dependencies of this object that can be object with class defined by client side and unknown for server.
      Specified by:
        `getDependencies` in interface `DeployableObject`

    - #### fromJSON

          public static KMeansModel fromJSON(Path path)

      Loads KMeansModel from JSON file.

    - #### toJSON

          public void toJSON(Path path)

      Specified by:
        `toJSON` in interface `JSONWritable`

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022