/** @import { InputType } from "../index.js" */ /** @import { ParametersKMeans } from "./index.js" */ /** * K-Means Clustering * * A popular clustering algorithm that partitions data into K clusters where each point * belongs to the cluster with the nearest mean (centroid). * * @class * @extends Clustering * @category Clustering * @see {@link KMedoids} for a more robust alternative * * @example * import * as druid from "@saehrimnir/druidjs"; * * const points = [[1, 1], [1.5, 1.5], [5, 5], [5.5, 5.5]]; * const kmeans = new druid.KMeans(points, { K: 2 }); * * const clusters = kmeans.get_cluster_list(); // [0, 0, 1, 1] * const centroids = kmeans.centroids; // center points */ export class KMeans extends Clustering { /** * @param {InputType} points * @param {Partial} parameters */ constructor(points: InputType, parameters?: Partial); _K: number; _randomizer: Randomizer; /** @type {number[]} */ _clusters: number[]; _cluster_centroids: Float64Array[]; /** @returns {number} The number of clusters */ get k(): number; /** @returns {Float64Array[]} The cluster centroids */ get centroids(): Float64Array[]; /** @returns {number[]} The cluster list */ get_cluster_list(): number[]; /** @returns {number[][]} An Array of clusters with the indices of the points. */ get_clusters(): number[][]; /** * @private * @param {number[]} point_indices * @param {number[]} candidates * @returns {number} */ private _furthest_point; /** * @private * @param {number} K * @returns {Float64Array[]} */ private _get_random_centroids; /** * @private * @param {Float64Array[]} cluster_centroids * @returns {{ clusters_changed: boolean; cluster_centroids: Float64Array[] }} */ private _iteration; /** * @private * @param {number} K * @returns {Float64Array[]} */ private _compute_centroid; } import type { ParametersKMeans } from "./index.js"; import { Clustering } from "./Clustering.js"; import { Randomizer } from "../util/index.js"; import type { InputType } from "../index.js"; //# sourceMappingURL=KMeans.d.ts.map