> ## 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.

# aggregateKMeans

<div className="kinetica-doxygen">
  <div id="ad5a2053d2dbd8781f49d4ce47c902c3e" />

  <h2 className="memtitle"><span className="permalink"><a href="#ad5a2053d2dbd8781f49d4ce47c902c3e">◆ </a></span>aggregateKMeans() <span className="overload">\[1/4]</span></h2>

  <div className="memitem">
    <div className="memproto">
      <table className="memname">
        <tr>
          <td className="memname"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">AggregateKMeansResponse</a> gpudb::GPUdb::aggregateKMeans </td>
          <td>(</td>
          <td className="paramtype">const <a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansRequest">AggregateKMeansRequest</a> &</td>
          <td className="paramname"><span className="paramname"><span className="em">request\_</span></span></td>
          <td>)</td>
          <td> const</td>
        </tr>
      </table>
    </div>

    <div className="memdoc">
      <p>This endpoint runs the k-means algorithm - a heuristic algorithm that attempts to do k-means clustering. </p>
      <p>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.</p>
      <p>NOTE: The Kinetica instance being accessed must be running a CUDA (GPU-based) build to service this request.</p>

      <div className="dl params">
        <div className="dt">Parameters</div>

        <div className="dd">
          <table className="params">
            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">request\_</td>
              <td><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansRequest">Request</a> object containing the parameters for the operation.</td>
            </tr>
          </table>
        </div>
      </div>

      <div className="dl section return">
        <div className="dt">Returns</div>
        <div className="dd"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">Response</a> object containing the result of the operation. </div>
      </div>
    </div>
  </div>

  <div id="ac94cd2cd6cbc6a3d01100b6565c76788" />

  <h2 className="memtitle"><span className="permalink"><a href="#ac94cd2cd6cbc6a3d01100b6565c76788">◆ </a></span>aggregateKMeans() <span className="overload">\[2/4]</span></h2>

  <div className="memitem">
    <div className="memproto">
      <table className="memname">
        <tr>
          <td className="memname"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">AggregateKMeansResponse</a> & gpudb::GPUdb::aggregateKMeans </td>
          <td>(</td>
          <td className="paramtype">const <a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansRequest">AggregateKMeansRequest</a> &</td>
          <td className="paramname"><span className="paramname"><span className="em">request\_</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">AggregateKMeansResponse</a> &</td>
          <td className="paramname"><span className="paramname"><span className="em">response\_</span></span> ) const</td>
        </tr>
      </table>
    </div>

    <div className="memdoc">
      <p>This endpoint runs the k-means algorithm - a heuristic algorithm that attempts to do k-means clustering. </p>
      <p>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.</p>
      <p>NOTE: The Kinetica instance being accessed must be running a CUDA (GPU-based) build to service this request.</p>

      <div className="dl params">
        <div className="dt">Parameters</div>

        <div className="dd">
          <table className="params">
            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">request\_</td>
              <td><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansRequest">Request</a> object containing the parameters for the operation. </td>
            </tr>

            <tr>
              <td className="paramdir">\[out]</td>
              <td className="paramname">response\_</td>
              <td><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">Response</a> object containing the results of the operation.</td>
            </tr>
          </table>
        </div>
      </div>

      <div className="dl section return">
        <div className="dt">Returns</div>
        <div className="dd"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">Response</a> object containing the result of the operation (initially passed in by reference). </div>
      </div>
    </div>
  </div>

  <div id="ac88006219510944c94cba1df8c2e71cd" />

  <h2 className="memtitle"><span className="permalink"><a href="#ac88006219510944c94cba1df8c2e71cd">◆ </a></span>aggregateKMeans() <span className="overload">\[3/4]</span></h2>

  <div className="memitem">
    <div className="memproto">
      <table className="memname">
        <tr>
          <td className="memname"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">AggregateKMeansResponse</a> gpudb::GPUdb::aggregateKMeans </td>
          <td>(</td>
          <td className="paramtype">const std::string &</td>
          <td className="paramname"><span className="paramname"><span className="em">tableName</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const std::vector\< std::string > &</td>
          <td className="paramname"><span className="paramname"><span className="em">columnNames</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const int32\_t</td>
          <td className="paramname"><span className="paramname"><span className="em">k</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const double</td>
          <td className="paramname"><span className="paramname"><span className="em">tolerance</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const std::map\< std::string, std::string > &</td>
          <td className="paramname"><span className="paramname"><span className="em">options</span></span> ) const</td>
        </tr>
      </table>
    </div>

    <div className="memdoc">
      <p>This endpoint runs the k-means algorithm - a heuristic algorithm that attempts to do k-means clustering. </p>
      <p>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.</p>
      <p>NOTE: The Kinetica instance being accessed must be running a CUDA (GPU-based) build to service this request.</p>

      <div className="dl params">
        <div className="dt">Parameters</div>

        <div className="dd">
          <table className="params">
            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">tableName</td>
              <td>Name of the table on which the operation will be performed. Must be an existing table, in \[schema\_name.]table\_name format, using standard <a href="/content/concepts/tables/#table-name-resolution" target="_top">name resolution rules</a>. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">columnNames</td>
              <td>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. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">k</td>
              <td>The number of mean points to be determined by the algorithm. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">tolerance</td>
              <td>Stop iterating when the distances between successive points is less than the given tolerance. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">options</td>

              <td>
                Optional parameters.

                <ul>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#accffe0d5bdce257dcd6fc2dcbfc4e114">aggregate\_k\_means\_whiten</a>: When set to 1 each of the columns is first normalized by its stdv - default is not to whiten. </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a935f1e072f932bc8077e0c420d7eaf0d">aggregate\_k\_means\_max\_iters</a>: Number of times to try to hit the tolerance limit before giving up - default is 10. </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#acaccbb0f7d7f66237de23f0a52b353c9">aggregate\_k\_means\_num\_tries</a>: Number of times to run the k-means algorithm with a different randomly selected starting points - helps avoid local minimum. Default is 1. </li>

                  <li>
                    <a className="el" href="/content/api/cpp/namespacegpudb#ac2dbbed6d5915b77fd2d96d822a45c56">aggregate\_k\_means\_create\_temp\_table</a>: If <a className="el" href="/content/api/cpp/namespacegpudb#a806315c06574b201e75ec323030fca04">true</a>, a unique temporary table name will be generated in the sys\_temp schema and used in place of <a className="el" href="/content/api/cpp/namespacegpudb#aaac1a56923c27501a783d47cf036f1e2">result\_table</a>. If <a className="el" href="/content/api/cpp/namespacegpudb#a7c89b6148e0de3beb043c8a4fc2dff15">result\_table\_persist</a> is <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">false</a> (or unspecified), then this is always allowed even if the caller does not have permission to create tables. The generated name is returned in <a className="el" href="/content/api/cpp/namespacegpudb#a3751e914a2b49c5dae04100e3298b086">qualified\_result\_table\_name</a>. Supported values:

                    <ul>
                      <li> <a className="el" href="/content/api/cpp/namespacegpudb#a806315c06574b201e75ec323030fca04">aggregate\_k\_means\_true</a> </li>
                      <li> <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">aggregate\_k\_means\_false</a> </li>
                    </ul>

                    The default value is <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">aggregate\_k\_means\_false</a>.
                  </li>

                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#aaac1a56923c27501a783d47cf036f1e2">aggregate\_k\_means\_result\_table</a>: The name of a table used to store the results, in \[schema\_name.]table\_name format, using standard <a href="/content/concepts/tables/#table-name-resolution" target="_top">name resolution rules</a> and meeting <a href="/content/concepts/tables/#table-naming-criteria" target="_top">table naming criteria</a>. If this option is specified, the results are not returned in the response. </li>

                  <li>
                    <a className="el" href="/content/api/cpp/namespacegpudb#a7c89b6148e0de3beb043c8a4fc2dff15">aggregate\_k\_means\_result\_table\_persist</a>: If <a className="el" href="/content/api/cpp/namespacegpudb#a806315c06574b201e75ec323030fca04">true</a>, then the result table specified in <a className="el" href="/content/api/cpp/namespacegpudb#aaac1a56923c27501a783d47cf036f1e2">result\_table</a> will be persisted and will not expire unless a <a className="el" href="/content/api/cpp/namespacegpudb#aa0654f4d5266cdd1a97095482e410298">ttl</a> is specified. If <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">false</a>, then the result table will be an in-memory table and will expire unless a <a className="el" href="/content/api/cpp/namespacegpudb#aa0654f4d5266cdd1a97095482e410298">ttl</a> is specified otherwise. Supported values:

                    <ul>
                      <li> <a className="el" href="/content/api/cpp/namespacegpudb#a806315c06574b201e75ec323030fca04">aggregate\_k\_means\_true</a> </li>
                      <li> <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">aggregate\_k\_means\_false</a> </li>
                    </ul>

                    The default value is <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">aggregate\_k\_means\_false</a>.
                  </li>

                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#aa0654f4d5266cdd1a97095482e410298">aggregate\_k\_means\_ttl</a>: Sets the <a href="/content/concepts/ttl/" target="_top">TTL</a> of the table specified in <a className="el" href="/content/api/cpp/namespacegpudb#aaac1a56923c27501a783d47cf036f1e2">result\_table</a>. </li>
                </ul>

                The default value is an empty map.
              </td>
            </tr>
          </table>
        </div>
      </div>

      <div className="dl section return">
        <div className="dt">Returns</div>
        <div className="dd"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">Response</a> object containing the result of the operation. </div>
      </div>
    </div>
  </div>

  <div id="a325a1fab76dc072b4bcbbe0890793bc1" />

  <h2 className="memtitle"><span className="permalink"><a href="#a325a1fab76dc072b4bcbbe0890793bc1">◆ </a></span>aggregateKMeans() <span className="overload">\[4/4]</span></h2>

  <div className="memitem">
    <div className="memproto">
      <table className="memname">
        <tr>
          <td className="memname"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">AggregateKMeansResponse</a> & gpudb::GPUdb::aggregateKMeans </td>
          <td>(</td>
          <td className="paramtype">const std::string &</td>
          <td className="paramname"><span className="paramname"><span className="em">tableName</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const std::vector\< std::string > &</td>
          <td className="paramname"><span className="paramname"><span className="em">columnNames</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const int32\_t</td>
          <td className="paramname"><span className="paramname"><span className="em">k</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const double</td>
          <td className="paramname"><span className="paramname"><span className="em">tolerance</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype">const std::map\< std::string, std::string > &</td>
          <td className="paramname"><span className="paramname"><span className="em">options</span></span>, </td>
        </tr>

        <tr>
          <td className="paramkey" />

          <td />

          <td className="paramtype"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">AggregateKMeansResponse</a> &</td>
          <td className="paramname"><span className="paramname"><span className="em">response\_</span></span> ) const</td>
        </tr>
      </table>
    </div>

    <div className="memdoc">
      <p>This endpoint runs the k-means algorithm - a heuristic algorithm that attempts to do k-means clustering. </p>
      <p>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.</p>
      <p>NOTE: The Kinetica instance being accessed must be running a CUDA (GPU-based) build to service this request.</p>

      <div className="dl params">
        <div className="dt">Parameters</div>

        <div className="dd">
          <table className="params">
            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">tableName</td>
              <td>Name of the table on which the operation will be performed. Must be an existing table, in \[schema\_name.]table\_name format, using standard <a href="/content/concepts/tables/#table-name-resolution" target="_top">name resolution rules</a>. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">columnNames</td>
              <td>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. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">k</td>
              <td>The number of mean points to be determined by the algorithm. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">tolerance</td>
              <td>Stop iterating when the distances between successive points is less than the given tolerance. </td>
            </tr>

            <tr>
              <td className="paramdir">\[in]</td>
              <td className="paramname">options</td>

              <td>
                Optional parameters.

                <ul>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#accffe0d5bdce257dcd6fc2dcbfc4e114">aggregate\_k\_means\_whiten</a>: When set to 1 each of the columns is first normalized by its stdv - default is not to whiten. </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#a935f1e072f932bc8077e0c420d7eaf0d">aggregate\_k\_means\_max\_iters</a>: Number of times to try to hit the tolerance limit before giving up - default is 10. </li>
                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#acaccbb0f7d7f66237de23f0a52b353c9">aggregate\_k\_means\_num\_tries</a>: Number of times to run the k-means algorithm with a different randomly selected starting points - helps avoid local minimum. Default is 1. </li>

                  <li>
                    <a className="el" href="/content/api/cpp/namespacegpudb#ac2dbbed6d5915b77fd2d96d822a45c56">aggregate\_k\_means\_create\_temp\_table</a>: If <a className="el" href="/content/api/cpp/namespacegpudb#a806315c06574b201e75ec323030fca04">true</a>, a unique temporary table name will be generated in the sys\_temp schema and used in place of <a className="el" href="/content/api/cpp/namespacegpudb#aaac1a56923c27501a783d47cf036f1e2">result\_table</a>. If <a className="el" href="/content/api/cpp/namespacegpudb#a7c89b6148e0de3beb043c8a4fc2dff15">result\_table\_persist</a> is <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">false</a> (or unspecified), then this is always allowed even if the caller does not have permission to create tables. The generated name is returned in <a className="el" href="/content/api/cpp/namespacegpudb#a3751e914a2b49c5dae04100e3298b086">qualified\_result\_table\_name</a>. Supported values:

                    <ul>
                      <li> <a className="el" href="/content/api/cpp/namespacegpudb#a806315c06574b201e75ec323030fca04">aggregate\_k\_means\_true</a> </li>
                      <li> <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">aggregate\_k\_means\_false</a> </li>
                    </ul>

                    The default value is <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">aggregate\_k\_means\_false</a>.
                  </li>

                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#aaac1a56923c27501a783d47cf036f1e2">aggregate\_k\_means\_result\_table</a>: The name of a table used to store the results, in \[schema\_name.]table\_name format, using standard <a href="/content/concepts/tables/#table-name-resolution" target="_top">name resolution rules</a> and meeting <a href="/content/concepts/tables/#table-naming-criteria" target="_top">table naming criteria</a>. If this option is specified, the results are not returned in the response. </li>

                  <li>
                    <a className="el" href="/content/api/cpp/namespacegpudb#a7c89b6148e0de3beb043c8a4fc2dff15">aggregate\_k\_means\_result\_table\_persist</a>: If <a className="el" href="/content/api/cpp/namespacegpudb#a806315c06574b201e75ec323030fca04">true</a>, then the result table specified in <a className="el" href="/content/api/cpp/namespacegpudb#aaac1a56923c27501a783d47cf036f1e2">result\_table</a> will be persisted and will not expire unless a <a className="el" href="/content/api/cpp/namespacegpudb#aa0654f4d5266cdd1a97095482e410298">ttl</a> is specified. If <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">false</a>, then the result table will be an in-memory table and will expire unless a <a className="el" href="/content/api/cpp/namespacegpudb#aa0654f4d5266cdd1a97095482e410298">ttl</a> is specified otherwise. Supported values:

                    <ul>
                      <li> <a className="el" href="/content/api/cpp/namespacegpudb#a806315c06574b201e75ec323030fca04">aggregate\_k\_means\_true</a> </li>
                      <li> <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">aggregate\_k\_means\_false</a> </li>
                    </ul>

                    The default value is <a className="el" href="/content/api/cpp/namespacegpudb#ac434edd0cd229d6b29ad08da700a6cee">aggregate\_k\_means\_false</a>.
                  </li>

                  <li> <a className="el" href="/content/api/cpp/namespacegpudb#aa0654f4d5266cdd1a97095482e410298">aggregate\_k\_means\_ttl</a>: Sets the <a href="/content/concepts/ttl/" target="_top">TTL</a> of the table specified in <a className="el" href="/content/api/cpp/namespacegpudb#aaac1a56923c27501a783d47cf036f1e2">result\_table</a>. </li>
                </ul>

                The default value is an empty map.
              </td>
            </tr>

            <tr>
              <td className="paramdir">\[out]</td>
              <td className="paramname">response\_</td>
              <td><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">Response</a> object containing the results of the operation.</td>
            </tr>
          </table>
        </div>
      </div>

      <div className="dl section return">
        <div className="dt">Returns</div>
        <div className="dd"><a className="el" href="/content/api/cpp/structgpudb_1_1AggregateKMeansResponse">Response</a> object containing the result of the operation (initially passed in by reference). </div>
      </div>
    </div>
  </div>
</div>
