// k-medoids clustering — like k-means, but cluster centres are actual elements, which makes it robust to outliers
eles.kMedoids(options?: KClusteringOptions): AlgoRun<Collection<NodeData, EdgeData, NodeData>[]>k-medoids clustering — like k-means, but cluster centres are actual elements, which makes it robust to outliers. Async, with the same executor contract as kMeans.
| Name | Description |
|---|---|
options: KClusteringOptions? | as |
Fields of options
| Name | Description |
|---|---|
k: number? | |
m: number? | |
sensitivityThreshold: number? | |
distance: DistanceMetric? | |
maxIterations: number? | |
attributes: KAttributeFn[]? | |
testMode: boolean? | |
testCentroids: number | FeatureCentroid[] | Collection[] | null? | |
executor: AlgoExecutor? | where the run executes; see |
AlgoRun<Collection<NodeData, EdgeData, NodeData>[]>a promise of one collection per cluster — with cancel() on it: a pending run rejects with CancelledError, a 'cpu' run has already completed
Example
const run = eles.kMedoids({ k: 2, attributes: [node => node.data('score')], executor: 'cpu' });const result = await run;console.log(result.reduce((sum, cluster) => sum + cluster.length, 0)); // 3if executor is invalid; rejects if executor: 'gpu' is unavailable, if executor: 'workers' is given a custom distance function, or if k exceeds the node count