> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# aggregate_k_means

### aggregate\_k\_means

<ul>
  <li>
    aggregate\_k\_means(\
    &#x20;table\_name: string,\
    &#x20;column\_names: string\[],\
    &#x20;k: number,\
    &#x20;tolerance: number,\
    &#x20;options?: Record\<string, string>,\
    &#x20;callback?: [GPUdbCallback](https://docs.kinetica.com/content/api/typescript/types/GPUdbCallback.md),\
    ): Promise\<[AggregateKMeansResponse](https://docs.kinetica.com/content/api/typescript/interfaces/AggregateKMeansResponse.md)>

    This endpoint runs the k-means algorithm - a heuristic algorithm that attempts to do k-means clustering. An ideal k-means clustering algorithm selects k points such that the sum of the mean squared distances of each member of the set to the nearest of the k points is minimized. The k-means algorithm however does not necessarily produce such an ideal cluster. It begins with a randomly selected set of k points and then refines the location of the points iteratively and settles to a local minimum. Various parameters and options are provided to control the heuristic search.NOTE: The Kinetica instance being accessed must be running a CUDA (GPU-based) build to service this request.

    #### Parameters

    <ul>
      <li>
        table\_name: string

        Name of the table on which the operation will be performed. Must be an existing table, in \[schema\_name.]table\_name format, using standard name resolution rules.
      </li>

      <li>
        column\_names: string\[]

        List of column names on which the operation would be performed. If n columns are provided then each of the k result points will have n dimensions corresponding to the n columns.
      </li>

      <li>
        k: number

        The number of mean points to be determined by the algorithm.
      </li>

      <li>
        tolerance: number

        Stop iterating when the distances between successive points is less than the given tolerance.
      </li>

      <li>
        `Optional`options: Record\<string, string>

        Optional parameters.
      </li>

      <li>
        `Optional`callback: [GPUdbCallback](https://docs.kinetica.com/content/api/typescript/types/GPUdbCallback.md)

        Optional callback function
      </li>
    </ul>

    #### Returns Promise\<[AggregateKMeansResponse](https://docs.kinetica.com/content/api/typescript/interfaces/AggregateKMeansResponse.md)>

    Promise\<Types.AggregateKMeansResponse> - Promise resolving to the response

    <ul>
      <li>Defined in [src/GPUdb.ts:3427](https://github.com/kineticadb/kinetica-api-typescript/blob/master/src/GPUdb.ts#L3427)</li>
    </ul>
  </li>
</ul>

### aggregate\_k\_means\_request

<ul>
  <li>
    aggregate\_k\_means\_request(\
    &#x20;request: [AggregateKMeansRequest](https://docs.kinetica.com/content/api/typescript/interfaces/AggregateKMeansRequest.md),\
    &#x20;callback?: [GPUdbCallback](https://docs.kinetica.com/content/api/typescript/types/GPUdbCallback.md),\
    ): Promise\<[AggregateKMeansResponse](https://docs.kinetica.com/content/api/typescript/interfaces/AggregateKMeansResponse.md)>

    This endpoint runs the k-means algorithm - a heuristic algorithm that attempts to do k-means clustering. An ideal k-means clustering algorithm selects k points such that the sum of the mean squared distances of each member of the set to the nearest of the k points is minimized. The k-means algorithm however does not necessarily produce such an ideal cluster. It begins with a randomly selected set of k points and then refines the location of the points iteratively and settles to a local minimum. Various parameters and options are provided to control the heuristic search.NOTE: The Kinetica instance being accessed must be running a CUDA (GPU-based) build to service this request.

    #### Parameters

    <ul>
      <li>
        request: [AggregateKMeansRequest](https://docs.kinetica.com/content/api/typescript/interfaces/AggregateKMeansRequest.md)

        Request object containing the parameters for the operation
      </li>

      <li>
        `Optional`callback: [GPUdbCallback](https://docs.kinetica.com/content/api/typescript/types/GPUdbCallback.md)

        Optional callback function
      </li>
    </ul>

    #### Returns Promise\<[AggregateKMeansResponse](https://docs.kinetica.com/content/api/typescript/interfaces/AggregateKMeansResponse.md)>

    Promise\<Types.AggregateKMeansResponse> - Promise resolving to the response

    <ul>
      <li>Defined in [src/GPUdb.ts:3387](https://github.com/kineticadb/kinetica-api-typescript/blob/master/src/GPUdb.ts#L3387)</li>
    </ul>
  </li>
</ul>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.